fix(importer): clamp over-long external text fields so imports do not hard-fail (#15) #37
No reviewers
Labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
public/wanderer!37
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/waypoint-description-clamp"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem (fixes #15)
The importer wrote external strings straight into records and
app.Saveaborts the entire trail import on any field-validation error. Reported case: a GPX waypoint description over thewaypointscollection's 5000-char limit (komoot POI descriptions routinely run 5-6.5k) killed the whole trail. The same failure mode applies to the other external text the importer writes — the waypoint name and the trail name/description — so over-long values there abort imports too (confirmed for waypoint name:name: Must be no more than 255 character(s)).Fix
Add
clampTextField(collection, field, value)— clamps to that field's own rune limit (read from the collection, no-op for unbounded/non-text fields), rune-safe with an ellipsis. Apply it to every external text fieldcreateWaypointsandImportTrailwrite (waypoint name+description, trail name+description). Mirrors the existingphotoFilesskip-don't-fail philosophy: no single over-long external value can abort an import.Tests (test-first)
TestCreateWaypointsClampsOverlongDescription— 6000-rune description; reproduced the exact abort before the fix.TestCreateWaypointsClampsOverlongName— 600-char name; reproducedname: Must be no more than 255 character(s)before the fix.TestClampToRuneLimit— table test (empty, under/at/over limit, multibyte, no-limit).plugins/importersuite +go vet+go build ./...green (CGO_ENABLED=0, go 1.25).Atomic, upstreamable. AI-assisted, disclosed (Co-Authored-By).
fix(importer): clamp over-long waypoint descriptions instead of failing the importto fix(importer): clamp over-long external text fields so imports do not hard-fail (#15)8aa3465565d45b7875e9Phase-1 catch-up review (upstream v0.21.2)
Rebased onto
main-v0.21.2, with the base retargeted. The old head is kept asarchive/fix-waypoint-description-clamp-pre-v0.21.2.Upstream fixed half of #15 in v0.21.1. #1320 added
util.SanitizeHTMLFieldsWithLimits(record)toImportTrailandcreateWaypoints. It shortens the rich-textdescriptionfields (trails, waypoints) to the field limit and is HTML-aware. Clamping the raw HTML first could cut a tag in half, so I addedd45b7875:namefields are clamped now.The clamp helper and tests for names are correct: rune-safe, using the field's own
Max, and a no-op for unbounded fields.Not run: go vet/test (CI on the NAS runner was paused tonight, and the run was cancelled). The old CI failures (7465/7476) were the node24-vs-runner-v6 issue (log: "got node24"), not the tests.
Verdict: needs work, then upstream it. Merging it into the fork has no live effect, because prodesk runs the upstream
flomp/wanderer-dbimage, not one built from this fork. Next steps:name: Must be no more than 255 character(s)) is still unhandled upstream as of v0.21.2.🤖 Generated with Claude Code
https://claude.ai/code/session_01M1AaXnEghenJ4BDxNryKvs