Request schema accepts source and attachment strings the runtime rejects, so schema-valid requests can still fail as malformed #178
Labels
No labels
priority/P0
priority/P1
priority/P2
release/v0.1.0
status/blocked
status/planned
type/bug
type/design
type/test-gap
type/tracker
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
natsukium/felis#178
Loading…
Reference in a new issue
No description provided.
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?
SessionsCaptureParams.sourceis typed as a bareOption<String>in the published schema, butcrates/felis-cli/src/cli_bridge.rs:1291-1295(and:1977-1981) requires it to parse viacrate::cli_sessions::parse_region_source, which accepts only a fixed small set of values and otherwise returnsBridgeError::malformed. SimilarlySessionsSwitchParams.attachmentis a bareOption<String>though the runtime table atcli_bridge.rs:754and its consumer only accept specific attachment tokens.A client can therefore construct a request that validates cleanly against the published bundle and still receives
malformed_requestfrom the live bridge: the published schema promises more than the runtime honors.Correction: add the
sourceenum's known values (or an equivalent pattern/enum forattachment) to the schema, or explicitly document in the schema description that the request schema is structural-only and does not encode these semantic value constraints.Reason deferred from #29: acceptance criterion 2 names only invalid ids, unknown fields, and out-of-range integers as required fixture coverage. Semantic enum-value validation for these string params is additional hardening beyond that criterion, and it would fall out naturally from the already-deferred per-op typed-params refactor.
Split from #29.
Triage note: #184 moves
parse_region_source(and the--formatparsers) ontoPossibleValuesParser/ValueEnum. IfSessionsCaptureParams.sourceis then typed with that same enum and the schema is derived from it, thesourcehalf of this issue falls out of #184 for free; onlyattachmentwould remain. Sequence this after #184 and re-check scope then.Triage plan (2026-09-07)
Decision (user, 2026-09-07): fix in v0.1. The published request schema is the v0.1 contract for bridge clients; a schema that accepts what the runtime refuses is a contract defect, not hardening.
status/blockedis lifted; the typed-params refactor deferred in #29 stays deferred.Approach
Minimal tightening of the generated bridge schema in
crates/felis-cli/src/cli_schema.rs:SessionsCaptureParams.source: an enum of exactly the valuesparse_region_sourceaccepts (after #187 lands this is theValueEnum's variant list; derive the schema from that type rather than a hand-written list so the two cannot drift).SessionsSwitchParams.attachment: the same pattern the CLI's attachment id uses (parse_attachment_idincli_sessions.rs), applied via the schema annotation the other id fields already carry.crates/felis-cli/schemas/felis-bridge-v1.schema.jsonwithjust schema.Not in scope: rewriting the bridge's
Paramsaccessors, or adding semantic constraints the runtime does not enforce.Tests
sessions.capturewithsource: "bogus"andsessions.switchwith a malformedattachment;tests/schema_fixtures.rsasserts the schema rejects them andcli_bridge.rsasserts the live bridge answersmalformed_request.allowed_params) is unchanged; add one assertion that thesourceenum in the published schema equals the runtime's accepted set.Cascade
docs/reference/cli.md"JSON Schema" section if it describes the request schema as structural-only (it should now say the finite string params are enumerated);CHANGELOG.mdUnreleased (schema tightened, pre-publish).Dependencies
After #187 (to derive the enum from the ValueEnum). If #187 is not merged when this starts, hand-list the four values and leave a comment naming the ValueEnum as the source to switch to.