fix(importer): clamp over-long external text fields so imports do not hard-fail (#15) #37

Open
jmz wants to merge 2 commits from fix/waypoint-description-clamp into main
Owner

Problem (fixes #15)

The importer wrote external strings straight into records and app.Save aborts the entire trail import on any field-validation error. Reported case: a GPX waypoint description over the waypoints collection'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 field createWaypoints and ImportTrail write (waypoint name+description, trail name+description). Mirrors the existing photoFiles skip-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; reproduced name: Must be no more than 255 character(s) before the fix.
  • TestClampToRuneLimit — table test (empty, under/at/over limit, multibyte, no-limit).
  • Full plugins/importer suite + go vet + go build ./... green (CGO_ENABLED=0, go 1.25).

Atomic, upstreamable. AI-assisted, disclosed (Co-Authored-By).

## Problem (fixes #15) The importer wrote external strings straight into records and `app.Save` **aborts the entire trail import** on any field-validation error. Reported case: a GPX waypoint description over the `waypoints` collection'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 field `createWaypoints` and `ImportTrail` write (waypoint name+description, trail name+description). Mirrors the existing `photoFiles` skip-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; reproduced `name: Must be no more than 255 character(s)` before the fix. - `TestClampToRuneLimit` — table test (empty, under/at/over limit, multibyte, no-limit). - Full `plugins/importer` suite + `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 import
Some checks failed
Go / db-test (pull_request) Failing after 3s
01e5af2223
A GPX waypoint whose description exceeds the waypoints collection's 5000
character limit made createWaypoints' app.Save return a validation error,
aborting the ENTIRE trail import — the track and every other waypoint were
lost, not just the one over-long POI. komoot highlight/POI descriptions
routinely run 5-6.5k characters, so bulk GPX imports of multi-day routes
failed outright (oss/wanderer #15).

Clamp the description to the collection's own description-field limit (rune-
safe, with an ellipsis) before saving, mirroring how photoFiles already skips
individual bad media rather than failing the whole trail.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
fix(importer): clamp all external text fields, not just waypoint description
Some checks failed
Go / db-test (pull_request) Failing after 2s
8aa3465565
Generalizes the #15 guard. The importer also wrote the trail name/description
and the waypoint name unclamped, so an over-long value in any of them aborted
the whole import the same way (confirmed for waypoint name:
'name: Must be no more than 255 character(s)').

Add clampTextField(collection, field, value), which clamps to that field's own
rune limit (no-op for unbounded/non-text fields), and apply it to every
external text field createWaypoints and ImportTrail write.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
jmz changed title from fix(importer): clamp over-long waypoint descriptions instead of failing the import to fix(importer): clamp over-long external text fields so imports do not hard-fail (#15) 2026-09-08 13:44:36 +00:00
Some checks failed
Go / db-test (pull_request) Failing after 2s
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin fix/waypoint-description-clamp:fix/waypoint-description-clamp
git switch fix/waypoint-description-clamp

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.

git switch main
git merge --no-ff fix/waypoint-description-clamp
git switch fix/waypoint-description-clamp
git rebase main
git switch main
git merge --ff-only fix/waypoint-description-clamp
git switch fix/waypoint-description-clamp
git rebase main
git switch main
git merge --no-ff fix/waypoint-description-clamp
git switch main
git merge --squash fix/waypoint-description-clamp
git switch main
git merge --ff-only fix/waypoint-description-clamp
git switch main
git merge fix/waypoint-description-clamp
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
public/wanderer!37
No description provided.