Repository navigation
fix(compilers/openapi): report an oauth2 scheme with no flow #727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0a97434
97b5fb2
a4c58cf
b87282c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -248,6 +248,18 @@ const ( | |
| // there. The document is invalid either way, since OpenAPI requires both | ||
| // fields. | ||
| IncompleteSecurityScheme = "openapi/incomplete-security-scheme" | ||
| // OAuth2NoFlow reports an oauth2 securitySchemes entry whose flows object | ||
| // is present but declares no flow — `flows: {}`, or only keys the model does | ||
| // not name — and which has no oauth2MetadataUrl to discover its endpoints | ||
| // from. The loader accepts that shape, so only the compiler sees it; an | ||
| // absent `flows` is the loader's own error and is not reported again | ||
| // (GitHub #646). Placed at the declaration, once however many aliases | ||
| // reach it. | ||
| // | ||
| // Reported, not refused as IncompleteSecurityScheme is: the IR states exactly | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "The IR states exactly what the document said" is the argument for interning, but
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Amended as suggested: |
||
| // what the document said, and refusing would drop the entry's text. A warning, | ||
| // like ReservedHeaderName, since the document lowers whole. | ||
| OAuth2NoFlow = "openapi/oauth2-no-flow" | ||
| // ReservedHeaderName reports a header declaration OpenAPI says SHALL be | ||
| // ignored, because the protocol layer already owns the name. Three positions: | ||
| // | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing the repo's sweeps reach exercises this rule, so everything outside this package's unit tests is blind to it. I deleted the feature (
if false && ...on the new branch, which compiles) and ran./compilers/openapi,./internal/harness/...,./ir/...,./pass/...and./cmd/.... All stayed green, includingTestConformance, the goldens andTestHarness_InRepoCorpus. Compiling the 154 specs undertestdata/, none drawsopenapi/oauth2-no-flow; the four that declaretype: oauth2all declare a flow.CLAUDE.md names the way to cover a new construct: add a spec the sweep reaches, so the no-panic,
irverify, round-trip, determinism and order-invariance oracles run over it, and a golden pins the diagnostic's code, pointer and severity byte for byte. The PR's test plan checks the existing fixtures and leavestestdata/alone, which is the gap. A conformance spec (testdata/conformance/openapi/:.yaml,.golden.jsonand a table row) should holdflows: {}, a flows object with only unknown keys, an aliased flowless scheme with the alias declared before its target (the order that would be wrong under a canonical-site bug), and a metadata-only 3.2.0 scheme as the silent control. I ran the harness on probes of these shapes and they pass, so adding them should be safe.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
testdata/conformance/openapi/oauth2-no-flow.yamlwith its golden and a table row (assertOAuth2NoFlow). It holdsflows: {}, a flows object with only an unknown key, two aliases declared before their flowless target, and two silent controls: a 3.2.0 metadata-only scheme and a declared flow.morphic-harnesspasses on it. With the feature deleted (if false && …),TestConformancenow reddens along with the unit tests. b87282c