Repository navigation
feat(ir)!: name a webhook binding's event - #735
Open
fuad-daoud wants to merge 3 commits into
Open
fuad-daoud wants to merge 3 commits into
fuad-daoud wants to merge 3 commits into
Conversation
An OpenAPI 3.1 webhooks entry is keyed by the name of the event the
provider sends, not a URL, so its operation's HTTPBinding carries that
key in WebhookName and leaves URITemplate empty. Storing it where RFC
6570 templates go made {tenant} read as a template variable nothing
binds.
WebhookName is the map key verbatim, a declared fact like Operation.Tags
or Naming.Source, not a neutral name channel and not a template. A
webhook binding carries no URITemplate; an empty webhooks key is legal
and leaves WebhookName empty. The synthesized naming hint is unchanged
(method + the webhook name).
irverify gains ir/webhook-uri-template: a webhook binding that populates
URITemplate selects a field a webhook does not, which the compiler's own
tests cannot hold for a foreign or pass-rewritten document.
IRVersion moves to 0.7.0: HTTPBinding gains a key, and a consumer pinned
to 0.6.0 that read a webhook's event name out of uriTemplate finds it in
no key it reads. Closes #624.
Resolve the conflicts with main and bring the doc comments this branch adds under the 100-word cap main now enforces. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GCzyGPq9DQ7RLfagZm2JB5
8 tasks done
Main took irVersion 0.7.0 for group IDs and idSpaces, so this change moves to 0.8.0: the constant, its ir-design.md history entry, the neighbour rows of TestCompatibleVersion and every golden. The webhook verify fixture gains a group ID and declares its ID spaces, which main's checks now require.
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
An OpenAPI 3.1 webhook's key is the name of the event the provider will send, not a URL, but the compiler stores it in
HTTPBinding.URITemplate:lowers to a binding with
"uriTemplate":"{tenant}.created"and"isWebhook":true. Storing it where RFC 6570 templates go makes{tenant}read as a template variable that nothing binds, and leaves no field naming the event.Change
ir.HTTPBindinggainsWebhookName string(json:"webhookName,omitempty") besideIsWebhook, holding the webhooks-map key verbatim — a declared fact likeOperation.TagsorNaming.Source, not a neutral name channel and not a template. A webhook binding carries that key inWebhookNameand leavesURITemplateempty. An empty webhooks-map key is legal and leaves the field empty.Nothing else moves: the operation's ID (mount pointer),
Name(theoperationId, or the synthesized hint), group, params, request and responses are unchanged. The synthesized hint for a webhook without anoperationIdstaysmethod + webhook name(post_tenant_created) — the naming token is the map key, not the now-empty template.irverifygainsir/webhook-uri-template: a binding withIsWebhookset that populatesURITemplateselects a field a webhook does not, and a consumer would have two answers and no way to tell which to trust. Only the negative half is a contract — an empty webhooks key is legal, so requiring a non-emptyWebhookNamewould fire on a legal document this compiler itself produces. This lives inirverifybecause a document decoded from JSON, written by another compiler, or rewritten by a pass is beyond what the compiler's own tests can hold.Callbacks are a different construct (a runtime expression, sometimes irreducible) and are left as they are; the same class of defect there is tracked separately.
Breaking
IRVersionmoves to 0.7.0.HTTPBindinggains a JSON key, and a webhook binding no longer writesuriTemplate— that key held an event name, not a template — so a consumer pinned to 0.6.0 finds the event name in no key it reads.Test plan
make gategreen; coverage is exactly 100%."webhookName":"{tenant}.created", nouriTemplate,isWebhooktrue, IDop/openapi/webhooks/{tenant}.created/post, hintpost_tenant_created.operationId, pinning the hint — taking the naming token from the emptyuriTemplateinstead would redden it.irverifytest: a webhook binding naming its event, a webhook with an empty key, and a path binding are all clean; a plantedIsWebhook+URITemplatereportsir/webhook-uri-templateat<binding>.URITemplate.uriTemplateand gainwebhookName; the other goldens change only in theirVersionline.unwitnessed.golden.txtis unchanged —WebhookNameis witnessed by the corpus.Merge ordering
This branch and the tuple-openness branch (#734) both set
IRVersionto0.7.0from the same base. Whichever merges second must rebase and take0.8.0, re-anchoringir/document_test.go's three literals and regenerating its goldens. If #734 lands first, rebase this ontomainand bump to0.8.0.