Skip to content

feat(engine): events_emit_raw — deliver provider-shaped webhook bodies - #55

Merged
deblasis merged 1 commit into
mainfrom
feat/events-emit-raw
Aug 16, 2026
Merged

feat(engine): events_emit_raw — deliver provider-shaped webhook bodies#55
deblasis merged 1 commit into
mainfrom
feat/events-emit-raw

Conversation

@deblasis

Copy link
Copy Markdown
Contributor

Some webhook receivers parse the delivery as the provider's own event object (Stripe: {"id","object":"event","type","data":{"object":…}}; GitHub similar) — the engine's {type, payload} envelope broke their SDK parsers even where the signature verified.

  • events primitive: Emitter.EmitRaw — delivers exact pre-marshaled bytes with Emit's retry/header/validation semantics; Emit now delegates to it after envelope marshal (byte-identical behavior for every existing adapter).
  • Starlark: events_emit_raw(event_type, body, headers?) builtin.
  • stripe-style: _signed_emit delivers the full Stripe event object; the same serialized bytes feed the HMAC and the POST, so webhooks.constructEvent(payload, sig, secret) verifies AND parses on the receiver — found by dogfooding a real stripe-node webhook receiver end-to-end.
  • Engine test proves raw delivery verbatim (no envelope wrap) + events_emit unchanged; stripe webhook tests now assert data.object payloads.
  • stunt llm reference corrected: the predeclared json module is json.decode/json.encode, not loads/dumps.

Gates: full suite, adapter lint (94), gofmt, vet — green.

Some providers' webhook receivers parse the delivery as the provider's
own event object (Stripe's id/object/type/data, GitHub's event JSON),
so the {type, payload} envelope breaks their SDK parsers even when the
signature verifies. EmitRaw delivers an exact pre-marshaled body with
Emit's retry/header/validation semantics; the events_emit_raw builtin
exposes it to Starlark. Found by dogfooding a real stripe-node receiver
against the stripe-style adapter.

stripe-style _signed_emit now delivers the full Stripe event object —
the same bytes are MAC'd and POSTed, so webhooks.constructEvent and
signature checks both run against the real shape. Engine test proves
raw delivery is verbatim while events_emit keeps the envelope; stripe
webhook tests assert data.object payloads now.

Also corrects the stunt llm reference: the predeclared json module is
json.decode/json.encode, not loads/dumps.
@deblasis
deblasis merged commit f4c9701 into main Aug 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant