fix(cli): variant date flags — variants add could never succeed - #9
Merged
Conversation
`mna variants add` had no way to set dates, and the API refuses to store a
variant without them, so every invocation came back as a bare `✖ HTTP 400`
(the 400 body carries no `message`, so there was nothing to explain it).
- New `--start-date` / `--end-date` (exact) and `--depart-not-before` /
`--depart-not-after` / `--return-not-before` / `--return-not-after` /
`--min-nights` / `--max-nights` (flexible) flags on `variants add` and
`variants edit`, following the `destinations --start-date/--end-date`
precedent and reusing `normalizeToIsoDateTime`.
- `variants add` fails fast client-side when no date flag is given, naming
both shapes, instead of sending a doomed request.
- Half-filled and mixed shapes are rejected locally on both commands — the
server rejects those too, again without a message. `variants edit` still
omits `dates` entirely when no date flag is given ("leave alone"), and can
never emit `dates: null`.
- Skill reference: event location coordinates are `lat`/`lng`, not
`latitude`/`longitude`. Verified against production — the documented form
is a 500, the corrected form round-trips.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AsdP2hvt4XQhYxkdNREXUq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was broken
mna variants addcould not succeed against production. A variant is what carries the trip'sdates, and the API rejects a create without them — but the command exposed no way to supply
them. Every invocation ended as:
The 400 body is
{"statusCode":400,"timestamp":…,"path":…}with nomessage, so the CLI hadnothing to print and the user had nothing to act on.
variants edithad the same gap in theother direction: no way to set dates at all, and no guard against the shapes the update path
rejects (
dates: null, half-filled{ startDate }).Confirmed directly against production before the fix:
POST …/variants {"name":"x"}POST …/variants {"name":"x","dates":{"startDate":…}}POST …/variants {"name":"x","dates":null}PATCH …/variants/<id> {"dates":null}PATCH …/variants/<id> {"dates":{"startDate":…}}PATCH …/variants/<id> {"name":"x"}(nodates)The fix
Date flags on
variants addandvariants edit, following thedestinations --start-date / --end-dateprecedent already onmainand reusingnormalizeToIsoDateTime(acceptsYYYY-MM-DDor a full ISO date-time). The v1 contract's two shapes map to two flag groups:--start-date,--end-date--depart-not-before,--depart-not-after,--return-not-before,--return-not-after,--min-nights,--max-nightsA new
src/commands/variants/dates.tsowns the flag definitions (spread into both commands) andthe body building, so the two commands cannot drift:
variants addusesrequireVariantDatesand fails fast client-side when no date flag isgiven, naming both shapes — no doomed request.
rejected as such. Night counts must be whole numbers.
variants editusesbuildVariantDates, which returnsundefinedwhen no date flag isgiven — so
datesis omitted entirely ("leave alone"), and the command has no path thatproduces
dates: nullor a partial object.Production round-trip evidence
Throwaway trip, both shapes, read back, deleted, cleanup confirmed — all through the CLI:
The edit round-trip also shows the "leave alone" path holding: a notes-only edit after the date
edit left
startDate/endDateintact.Client-side guards, no request sent:
Event location coordinates — doc correction
skills/mna/references/cli-and-schemas.mddocumented event location coordinates ascoordinates.latitude/.longitude.CreateEventLocationCoordinatesV1Dtorequireslat/lng,and production agrees — verified on the same throwaway trip via
mna events add --from-json:location.coordinates{"lat":38.7075,"lng":-9.1364}{"lat":38.7075,"lng":-9.1364}+formattedAddresspersisted{"latitude":38.7139,"longitude":-9.1334}address/latitude/longitude(nocoordinates)namesurvivesSo the documented form wasn't a silent drop — it was a server error. Doc corrected to
lat/lngfor event locations too. The neighbouring accommodation/transport location paragraph is left
untouched; #8 owns that one.
Prior art
mainalready carries the date-flag design from4198ed5(destinations --start-date/--end-datesrc/util/dates.ts) — it survived the stacked-PR merge. Nothing was lost, and nothing neededresurrecting; this change follows that design rather than inventing a second one.
Gates
bun run codegen(no-op vs the committed snapshot) ·bun run typecheck✓ ·bun run lint✓ (227 files, no findings) ·bun test✓ 142 pass / 0 fail ·bun run build✓. 14 new tests: unit coverage of every rejection path inbuildVariantDates/requireVariantDates, plus fetch-stub tests asserting the exactadd/editrequest bodies.🤖 Generated with Claude Code
https://claude.ai/code/session_01AsdP2hvt4XQhYxkdNREXUq