fix(responses): reject ambiguous timestamp prefixes in show - #17
Open
dchaudhari7177 wants to merge 1 commit into
Open
fix(responses): reject ambiguous timestamp prefixes in show#17dchaudhari7177 wants to merge 1 commit into
dchaudhari7177 wants to merge 1 commit into
Conversation
`survey responses <id> show <prefix>` returned the first match when the prefix matched more than one timestamp, so a user could inspect the wrong response with no warning. deleteResponse already rejected this case. readResponse now resolves the same way deleteResponse does: collect every matching entry, return null for none, throw AmbiguousResponsePrefixError for more than one. The CLI's show branch moves inside the existing try/catch that already renders that error for delete. Resolution also moves from listResponses (which matches the timestamp inside the JSON) to the enumerated filename, matching deleteResponse's 'filename is the authoritative identity' rule. Without that, a response with corrupt metadata could make `show <prefix>` and `delete <prefix>` resolve to different responses. Closes crafter-station#13
|
@dchaudhari7177 is attempting to deploy a commit to the Crafter Station Team on Vercel. A member of the Team first needs to authorize it. |
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.
Closes #13.
survey responses <id> show <prefix>returned the first match when the prefix matched more than one timestamp — exit 0, no warning, potentially the wrong response.deletealready rejected this.What changed
readResponsenow mirrorsdeleteResponse: collect every matching entry, returnnullfor none, throwAmbiguousResponsePrefixErrorfor more than one. Incli.tstheshowbranch moves inside thetry/catchthat already renders that error fordelete, so both commands report ambiguity identically.One thing beyond the literal ask, which I think is the right call but is worth a look: resolution also moves from
listResponses(which matched on thetimestampfield inside the JSON) to the enumerated filename — the ruledeleteResponsealready documents as "the enumerated filename is the authoritative response identity". Left as-is, a response whose metadata timestamp disagreed with its filename would makeshow <prefix>anddelete <prefix>resolve to different responses. There's a test pinning that. Say the word if you'd rather keep the change strictly to the ambiguity check.Acceptance
showstill accepts an exact timestamp and a unique prefixVerification
bun run typecheckclean.bun teston this branch: 46 pass, 3 fail. Baseline onmain: 40 pass, 3 fail — same three failures, so the 6 new tests pass and nothing regressed.Both numbers are with
NO_COLOR=1. Without it I get 5 failures onmain, and the two extra are an environment artifact worth knowing about: picocolors detects colour support on this terminal, sodocumented responses show/delete syntaxfail comparing"Deleted …"against"\x1b[2mDeleted …\x1b[22m". Not related to this change — they fail identically on pristinemain.The 3 remaining failures (
discoverSurveyFiles, twostandalone scaffold) are also pre-existing;discoverSurveyFilesis a Windows path-separator issue, returning absolute paths where the test expects bare filenames.