Repository navigation
fix(codegen): auth signs in an operation whose spec says security: [] - #634
Merged
Merged
Conversation
With `auth` (the CLI's own sign-in scheme), `generate` kept an operation's
`security: []`. cli-core's authHeader reads that as "no sign-in", so the
call went out without the key. hubspot-cli 0.1.0 sent 115 api calls
(deals-get, contacts-list...) that way and HubSpot answered 401: its object
specs put `security: []` on those operations.
Rule: with `auth`, an operation keeps its own `security` only when it signs
in by auth's schemes (at least one non-empty requirement, every name one of
auth's). `[]`, `[{}]` and requirements naming the source's own schemes fall
back to auth's `security`. Passing `auth` already says the source's sign-in
is wrong; a key sent to a public call is ignored, a key left off a private
call always fails. No CLI needs a public call under auth today (Yandex Disk
has no operation-level security). If one ever does, it needs a new option:
`Override` has no security field, and overrides run before `auth`.
Without `auth`, `[]` still means "no sign-in".
The rule reuses signInRequirements, so "signs in" means the same here as in
the fake API and cli-core.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
leemour
added a commit
that referenced
this pull request
Nov 17, 2026
Dates the release as 0.115.0, carrying #635 (the `graphql` spec kind, Added → minor) and #634 (`auth` signs in an operation whose spec says `security: []`). Only package.json and the CHANGELOG change; `bin/release` publishes it after the merge. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Task
With
auth(the CLI's own sign-in scheme),generatekept an operation'ssecurity: []. cli-core'sauthHeaderreads an empty list as "no sign-in", so the request went out without the key.Why
hubspot-cli 0.1.0 sent 115
apioperations (deals-get,contacts-list…) without the key, and HubSpot answered 401. HubSpot's object specs (calls, companies, contacts, deals, emails, leads, meetings, notes, tasks, tickets) putsecurity: []on those operations themselves; the document has no top-levelsecurity. hubspot-cli works around it insrc/config.ts.The rule
With
auth, an operation keeps its ownsecurityonly when it signs in byauth's schemes: at least one non-empty requirement, and every name is one ofauth's.[],[{}]and requirements naming the source's own schemes getauth'ssecurity. An optional sign-in ([{}, { token: [] }]) is kept. Withoutauth,[]still means "no sign-in".Why not keep
[]for a truly public call (a health check, a token exchange):authalready says the source's sign-in is wrong. An empty list from that same source is no more trustworthy.authtoday: Yandex Disk, the other user ofauth, has no operation-levelsecurity.If a CLI ever needs one, it needs a new option.
Overridehas nosecurityfield, and overrides run beforeauth. Not built now."Signs in" reuses
signInRequirements, so it means the same here as in the fake API and in cli-core.What
src/codegen/pipeline.ts:applyAuthkeeps an operation'ssecurityonly when it signs in byauth's schemes.codegen.test.tsfor[],[{}], a source scheme, an auth scheme and an optional sign-in, with and withoutauth. The existingopenapi.test.tscase that pinned the old behaviour (/healthkeeping[]) now expects it replaced.docs/standards/kit-surface.mdandCHANGELOG.md(Unreleased, Fixed).Testing
pnpm vitest run src/codegen: 119 passed. The two affected tests fail on the oldpipeline.ts.pnpm typecheck,pnpm biome check .(no new warnings),pnpm docs:check: pass.Follow-up for hubspot-cli after it bumps to the release with this fix: drop the
securityworkaround insrc/config.ts, and invert the assertion insrc/api.test.ts:94that expects an operation with an emptysecurity.🤖 Generated with Claude Code