D3b: api command edge-value validation (C11+C12+C13)#6
Merged
Conversation
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.
Summary
Three MED findings from the C-audit, all in
pkg/cmd/api. Single-file blast radius, cohesive fix.api --paginateagainst a non-array endpoint silently wrapped the single object in[obj]. Scripts likeapi repos/o/r --paginate | jq '.[]'got exactly one element and assumed pagination "worked". Now errors:api: --paginate requires a JSON array response; <endpoint> did not return one.api -f q=hello /searchon a GET silently sent a JSON body. Server rejected with a confusing parse error. gh-compat behavior: fields on GET become?key=valuequery params. New helperqueryStringFromFieldshandles the conversion (including@fileexpansion for-F).api -t '{{.totally_missing}}'printed the literal<no value>and exited 0. text/template's default behavior — useless under CLI scripting where missing fields should fail loudly. Now usesOption("missingkey=error").Test plan
TestRunTemplateRejectsMissingKey—{{.totally_missing}}errors; stdout never contains<no value>.TestRunGETWithFieldsBecomesQueryString—GET /search -f q=hello -f sort=starslands as?q=hello&sort=stars.TestRunPaginateRejectsNonArrayResponse—--paginateon/user(object response) errors mentioning "JSON array".pkg/cmd/apitests (includingTestRunPaginateConcatArray, template execution, mutex) still green.make cigreen locally.Notes for follow-up (deferred from this PR)
--max-pages 0/-1) — the audit flagged this as "silently no-cap", but the help text documents0 → default(30) and-1 → no cap. Needs deeper investigation: does the audit's repro actually disagree with the documented behavior? Skipping until verified.--limit 0/-1) — separate batch (touches many commands, not justapi). Lands as D3b-2.secret setname regex) — single-file fix, separate small PR.