Clear meta_date_end when a document's precision leaves RANGE #707
Reference in New Issue
Block a user
Delete Branch "%!s()"
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?
Context
Follow-up from PR #706 / issue #678 (review by "Elicit" — Requirements Engineer).
Issue #678 assumed "the edit form clears the end field off-RANGE", and on that basis treated the "end date set without RANGE precision" guard (predicate 2 of
validateDateRange) as API-only defense. That assumption is factually wrong:value={showEndDate ? endDateIso : ''}, so off-RANGE it POSTsmetaDateEnd=''.nullLocalDateonDocumentUpdateDTO.DocumentService.applyDatePrecisiononly applies a DTO field when it is non-null — so a null end is skipped, not cleared.Net effect: if a document is stored as
RANGEwith an end date and the user switches its precision to, say,MONTHon the form, the previously-stored end date is retained. The post-apply state is thenprecision != RANGE && metaDateEnd != null, which:chk_meta_date_end_only_for_range→ HTTP 500.INVALID_DATE_RANGE, but the user-facing message is "The end date must not be before the start date." — the wrong sentence for this situation, and the action (a legitimate precision change) still fails.#678 deliberately kept predicate 2 as a reject (its AC6 asserts a 400), so fixing this could not be done within that PR without contradicting a locked acceptance criterion. Hence this follow-up.
Requirement
This is the inverse of the progressive-disclosure UI: leaving RANGE should discard the now-meaningless end date, not preserve-and-reject it.
Acceptance criteria
Implementation sketch
DocumentService.applyDatePrecision(or a small dedicated step right after it), when the resultingmetaDatePrecision != RANGE, setmetaDateEnd = null(and arguablymetaDateRawleft as-is). This removes predicate 2's only realistic user-facing trigger.validateDateRange's second predicate: once the end is cleared on precision change, predicate 2 becomes pure API-defense as #678 originally intended — keep it, but if AC2 picks option (b), give it its own ErrorCode/message rather than sharingINVALID_DATE_RANGE.DocumentServiceTestcase for the RANGE→MONTH form switch clearing the end; keep #678's predicate-2 test aligned with whichever AC2 contract is chosen.Notes / scope