fix: reconcile JourneyItem note maxlength — frontend caps at 2000, backend accepts 5000 #793

Open
opened 2026-06-09 16:17:51 +02:00 by marcel · 0 comments
Owner

Problem

JourneyItemRow.svelte enforces maxlength="2000" on the note textarea, matching the spec. But the backend constant JourneyItemService.MAX_NOTE_LENGTH is set to 5000 characters — no @Size or @Valid constraint enforces this at the HTTP boundary.

This creates an inconsistent contract:

  • Notes saved via the JourneyEditor UI are capped at 2000 chars.
  • Notes saved via a direct PATCH /api/geschichten/{id}/items/{itemId} API call can be up to 5000 chars.
  • If a 4000-char note is saved via the API, the JourneyItemRow textarea's bind:value will load all 4000 chars — but the maxlength="2000" attribute silently prevents the user from editing beyond that point, and a blur-triggered onNotePatch call would truncate the content.

Decision needed

One of these must be chosen before this stays in production:

  • Option A (raise frontend): Update maxlength to 5000 in JourneyItemRow.svelte and the spec. The backend is the source of truth.
  • Option B (lower backend): Add a @Size(max = 2000) validation to the PATCH DTO and update MAX_NOTE_LENGTH to 2000. The spec is the source of truth.

Acceptance criteria

  • maxlength in JourneyItemRow.svelte matches the backend constraint
  • Backend returns a JOURNEY_NOTE_TOO_LONG error (400) when the limit is exceeded via API — regardless of the chosen limit
  • Spec HTML updated to match the resolved limit
  • No silent truncation is possible: API and UI enforce the same cap

Context

Surfaced during PR review of #792 (JourneyEditor frontend). The PR description acknowledges the discrepancy; this issue tracks the resolution.

## Problem `JourneyItemRow.svelte` enforces `maxlength="2000"` on the note textarea, matching the spec. But the backend constant `JourneyItemService.MAX_NOTE_LENGTH` is set to **5000** characters — no `@Size` or `@Valid` constraint enforces this at the HTTP boundary. This creates an inconsistent contract: - Notes saved via the `JourneyEditor` UI are capped at 2000 chars. - Notes saved via a direct `PATCH /api/geschichten/{id}/items/{itemId}` API call can be up to 5000 chars. - If a 4000-char note is saved via the API, the `JourneyItemRow` textarea's `bind:value` will load all 4000 chars — but the `maxlength="2000"` attribute silently prevents the user from editing beyond that point, and a blur-triggered `onNotePatch` call would truncate the content. ## Decision needed One of these must be chosen before this stays in production: - **Option A (raise frontend):** Update `maxlength` to `5000` in `JourneyItemRow.svelte` and the spec. The backend is the source of truth. - **Option B (lower backend):** Add a `@Size(max = 2000)` validation to the PATCH DTO and update `MAX_NOTE_LENGTH` to 2000. The spec is the source of truth. ## Acceptance criteria - [ ] `maxlength` in `JourneyItemRow.svelte` matches the backend constraint - [ ] Backend returns a `JOURNEY_NOTE_TOO_LONG` error (`400`) when the limit is exceeded via API — regardless of the chosen limit - [ ] Spec HTML updated to match the resolved limit - [ ] No silent truncation is possible: API and UI enforce the same cap ## Context Surfaced during PR review of #792 (JourneyEditor frontend). The PR description acknowledges the discrepancy; this issue tracks the resolution.
marcel added the P1-highbug labels 2026-06-09 16:17:54 +02:00
Sign in to join this conversation.
No Label P1-high bug
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: marcel/familienarchiv#793