fix(importer): clamp over-long external text fields so imports do not hard-fail (#15) #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)View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.