feat: configurable operation-4xx-response (excludeMethods); add tests… - #3028
feat: configurable operation-4xx-response (excludeMethods); add tests…#3028jeremyfiel wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 17c84be The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
89e3d99 to
e4533ab
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e4533ab. Configure here.
e4533ab to
17c84be
Compare
Performance Benchmark (Lower is Faster)
|
| | ---------------- | ------- | ----------------------------------------------------------------------------------------------------------- | | ||
| | severity | string | Possible values: `off`, `warn`, `error`. Default `warn` (in `recommended` configuration). | | ||
| | validateWebhooks | boolean | Determines if responses inside webhooks are validated. Default `false`. | | ||
| | excludeMethods | array | List of HTTP methods (case-insensitive) to exclude from 4XX validation. Default: `['get','head','options']` | |
There was a problem hiding this comment.
I'm not sure if this should be the default. GET requests can still have 4xx responses like 401, 403, 429 which could be documented and the documentation could help consumers and code gen.
| export const Operation4xxResponse: Oas3Rule | Oas2Rule = ({ validateWebhooks }) => { | ||
| export const Operation4xxResponse: Oas3Rule | Oas2Rule = (opts: any = {}) => { | ||
| const { validateWebhooks, excludeMethods: rawExcludeMethods } = opts || {}; | ||
| const defaultExcluded = ['get', 'head', 'options']; |
There was a problem hiding this comment.
| const defaultExcluded = ['get', 'head', 'options']; | |
| const defaultExcluded = ['options']; |
I think I would start with this possibly.
Also, even this is a breaking change.

What/Why/How?
What:
Why:
How:
Files changed (high level)
Reference
Testing
Local verification steps (repo root):
npm run unit -- packages/core/src/rules/common/tests/operation-4xx-response.exclude.test.ts
CI:
Screenshots (optional)
n/a
Check yourself
Security
Note
Medium Risk
Default lint behavior changes for a common rule: GET/HEAD/OPTIONS no longer require documented 4XX responses unless users override
excludeMethods, which may surprise teams on strict presets.Overview
The
operation-4xx-responserule now skips 4XX checks for configurable HTTP methods, withget,head, andoptionsexcluded by default. Validation runs at the Operation level (instead of on the responses map alone) so the verb is available; webhook operations follow the same rules whenvalidateWebhooksis enabled. Lint locations still point atoperation.responses.Projects can extend exclusions via
excludeMethods(documented with an example) or restore strict checks for every method by overriding that list (e.g. an empty array). Unit tests cover default exclusion for GET and enforcement for POST.Reviewed by Cursor Bugbot for commit 17c84be. Bugbot is set up for automated code reviews on this repo. Configure here.