fix(cookiy.sh): die on flags missing required values; tighten guide update - #44
Open
yupeng-dev wants to merge 1 commit into
Open
fix(cookiy.sh): die on flags missing required values; tighten guide update#44yupeng-dev wants to merge 1 commit into
yupeng-dev wants to merge 1 commit into
Conversation
…pdate
build_json silently substituted the literal string "true" for any --flag
whose next token began with "--" (or was end-of-args). For required
string fields like --base-revision and --idempotency-key, this produced
JSON like {"base_revision":"true","idempotency_key":"true"} — a 4-char
placeholder that shipped to the server and was rejected by zod
.min(8) as invalid_discussion_guide_patch_body.
Changes:
- build_json now keeps the implicit "true" default only for an explicit
whitelist of boolean flags (include_raw, skip_synthetic_interview,
include_incomplete). Any other flag without a value triggers a clear
local die: "--foo requires a value (got next flag or end of args)".
- New require_min_string_length helper mirrors server-side zod min(N)
on string fields, producing a precise local error before any HTTP.
- "study guide update" uses require_min_string_length 8 for
base_revision and idempotency_key, matching the server contract.
Repro of original bug:
bash cookiy.sh study guide update --study-id S \
--base-revision $UNSET --idempotency-key K12345678 --json '{"x":1}'
Before: 400 invalid_discussion_guide_patch_body from server.
After: --base-revision requires a value (got next flag or end of args)
Made-with: Cursor
janzayas1-cmyk
approved these changes
Jun 6, 2026
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.
Problem
build_jsonsilently substituted the literal string"true"for any--flagwhose next token began with--(or was end-of-args). For required string fields like--base-revisionand--idempotency-key, this produced JSON like:{"base_revision":"true","idempotency_key":"true", ...}— a 4-character placeholder that shipped to the server and was rejected by zod
.min(8)asinvalid_discussion_guide_patch_body. Users saw a confusing 400 round-trip instead of a clear local error.Reproduction:
Before:
{"ok":false,"status_code":400,"error":{"code":"BAD_REQUEST","message":"invalid_discussion_guide_patch_body","details":{"issues":[{"path":"base_revision","message":"String must contain at least 8 character(s)"}, ...]}}}After:
Changes
build_json— keep the implicit"true"default only for an explicit boolean-flag whitelist (include_raw,skip_synthetic_interview,include_incomplete). Any other flag without a value triggers a clear localdie.require_min_string_lengthhelper — mirrors server-side zod.min(N)on string fields, producing a precise local error before any HTTP.study guide update— usesrequire_min_string_length 8forbase_revisionandidempotency_key, matching the server contract.Test plan
bash -n cookiy.sh— syntax OK--base-revision $UNSET --idempotency-key K... --json ...→ dies with clear message--base-revision ""→ dies with<string of length >= 8>--base-revision short→ dies client-side instead of round-tripping--include-incomplete(in commands that accept it) still defaults totrueNo backend changes required; behavior change is strictly safer (silent corruption → loud, local error).
Made with Cursor