fix(asm): resolve invalid webhook payload schema (readOnly/requestBody conflict)#59
Open
dmchaledev wants to merge 1 commit into
Open
fix(asm): resolve invalid webhook payload schema (readOnly/requestBody conflict)#59dmchaledev wants to merge 1 commit into
dmchaledev wants to merge 1 commit into
Conversation
…y conflict)
The scanStatusChanged webhook's requestBody referenced ScanDetail, whose
id/created_at/started_at/completed_at/summary fields are marked readOnly
for the resource-oriented GET /scans/{id} response. Because OpenAPI models
each `webhooks` entry as a requestBody, those readOnly fields are invalid
in a client-request context — Redocly's linter flags every one of the
committed examples as non-conforming, and any codegen tool honoring
readOnly would silently strip the very fields the payload exists to
deliver. Added a dedicated ScanWebhookPayload schema without the readOnly
markers and gave the operation an operationId.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QPR3wQF4xgX1u9tTRwszJs
1 task
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
asm/openapi.yaml'sscanStatusChangedwebhookrequestBodyreferenced#/components/schemas/ScanDetailfor itsdatafield.ScanDetail(viaScan) marksid,created_at,started_at,completed_at, andsummaryasreadOnly: true— correct for the resource-orientedGET /scans/{id}response, where those fields are server-set and excludedfrom anything the client writes.
The problem: the OpenAPI
webhookskeyword models every entry as arequestBody, i.e. a client-request context.readOnlyproperties areinvalid in that context, so reusing
ScanDetailhere made every one of thespec's own committed webhook examples (
completed/failed) non-conforming— confirmed with
@redocly/cli lint, which reported 9 warnings, one perreadOnly field referenced in the examples, plus a missing
operationId.Spectral (this repo's CI gate) doesn't check this, which is why it went
unnoticed.
Beyond the lint noise, this is a real risk for anyone generating a client
or mock server from the spec: tooling that honors
readOnly(many OpenAPIcodegen tools do) would strip exactly the fields —
id, timestamps,summary— that make the webhook payload useful, silently producing agenerated type that's missing most of the payload.
Fix
ScanWebhookPayloadschema: structurally identical toScanDetail, but without thereadOnlymarkers, since in a webhookdelivery those fields are exactly what's being sent, not something the
subscriber could write back.
datafield at the new schema instead ofScanDetail.operationId: scanStatusChangedon the webhookoperation.
— it was the schema modeling that was wrong).
Pre-flight duplicate check
file(s)/endpoint(s) and did not find an existing one already
covering this change. The three currently open issues (sat/openapi.yaml: several write endpoints are missing a requestBody schema #39, Pin third-party GitHub Actions to full-length commit SHAs (supply-chain hardening) #57,
sat/openapi.yaml: no 429/rate-limit documentation anywhere (inconsistent with asm/openapi.yaml) #58) touch
sat/openapi.yamland CI workflow files respectively;none overlap with the ASM webhooks section.
Related issues/PRs
None — no existing issue/PR covers this.
Testing
npx @redocly/cli@latest lint asm/openapi.yaml— went from 9 warnings toa clean pass (
Woohoo! Your API description is valid.).npx @stoplight/spectral-cli@6.16.0 lint asm/openapi.yaml --ruleset .spectral.yaml --fail-severity error— still 0 errors (this repo's existing CI gate), confirming no
regression there.
Generated by Claude Code