Skip to content

fix(api): refuse an empty required argument before sending - #3353

Merged
leemour merged 2 commits into
mainfrom
fix/api-empty-required
Nov 25, 2026
Merged

leemour merged 2 commits into
mainfrom
fix/api-empty-required

Conversation

@leemour

@leemour leemour commented Nov 25, 2026

Copy link
Copy Markdown
Member

Task

linear live api issue-delete --id "" --yes --json sent the request. It answered exit 14 outcome.unknown ("Linear did not confirm a write"). A required argument that is empty must be refused locally before any request, with exit 2 input.invalid, naming the flag. OpenAPI CLIs must behave the same.

What

  • generatedApiCommand refuses a required path, query or header parameter that is empty or only spaces, before anything is sent. It answers validation_error, which is exit 2 with reason input.invalid, and the details say sent: false. On OpenAPI an empty path segment could reach another endpoint (/posts/).
  • graphqlVariables treats a blank required variable as missing, from a flag or from --body. This covers the command and serviceApiWriter.
  • serviceApiWriter refuses a blank required path, query or header parameter from code too.
  • A bot API body field (rpc) is still sent when it is empty. Telegram documents setWebhook --url "" as the way to remove a webhook, and tg-cli marks url as required. The review found this.
  • A missing required field inside an input object was already refused by the generated request schema. I checked this on linear: issue-create --input '{}' gives exit 2 and names input.teamId.
  • Changelog fragment: changes/fix-api-empty-required.md.

Testing

  • New tests:
    • GraphQL: --id "", --id " " and --body '{"id":""}' each give exit 2 and name --id, and nothing is sent.
    • OpenAPI: a path parameter is refused by the command and by the writer.
    • Bot: a required query parameter is refused, and an empty rpc body field still goes through.
  • I checked that the GraphQL and OpenAPI tests fail without the fix.
  • src/cli/service-api*, src/cli/bot and src/parity pass. pnpm ci:quick, pnpm lint and pnpm docs:check pass.
  • I built linear-cli release/1.0 against a local pack in a temp worktree with throwaway config folders and no sign-in. linear live api issue-delete --id "" --yes --json now prints {"error":{"code":"validation_error","reason":"input.invalid","message":"issue-delete needs --id","details":{"sent":false}}} with exit 2.

The companion cli-base PR is WireCatLabs/cli-base#726 (api skill groups by entity).

🤖 Generated with Claude Code

leemour and others added 2 commits November 25, 2026 11:06
A generated api command sent a required flag given as "" or spaces:
`linear api issue-delete --id "" --yes` reached Linear and answered
exit 14 outcome.unknown. Commander's mandatory check only rejects a
missing flag, and graphqlVariables only rejected null.

Now a required parameter (flag, path, query, header) or a required
GraphQL variable from --body that is blank is refused with
validation_error (exit 2, input.invalid), naming the flag, and nothing
is sent. serviceApiWriter refuses the same for code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Telegram's setWebhook takes an empty required url to remove the hook,
so the blank check covers path, query and header parameters; GraphQL
variables are checked in graphqlVariables.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leemour
leemour merged commit 7e96cb2 into main Nov 25, 2026
38 of 41 checks passed
@leemour
leemour deleted the fix/api-empty-required branch November 25, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant