Skip to content

Fix: Webhook responses, event info on context, internal fix for labels matches#3625

Merged
mrkaye97 merged 34 commits intomainfrom
mk/dont-send-back-full-webhook-payload
Apr 22, 2026
Merged

Fix: Webhook responses, event info on context, internal fix for labels matches#3625
mrkaye97 merged 34 commits intomainfrom
mk/dont-send-back-full-webhook-payload

Conversation

@mrkaye97
Copy link
Copy Markdown
Contributor

@mrkaye97 mrkaye97 commented Apr 15, 2026

Description

Fixes a couple things:

  1. Adds a switch in the webhooks UI to shut off sending back the event that the webhook creates as the response to protect any sensitive info
  2. Adds a couple new properties to the context (triggering_event_id and triggering_event_key) to be able to see what event triggered any given task, if any
  3. Refactors internally because I realized in implementing the events thing that I implemented the label storage wrong, which explains why I was confused about the dag data

Webhooks ui:

update:
Screenshot 2026-04-15 at 4 23 37 PM

create:
Screenshot 2026-04-15 at 4 23 52 PM

Type of change

  • New feature (non-breaking change which adds functionality)

Copilot AI review requested due to automatic review settings April 15, 2026 20:21
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hatchet-docs Ready Ready Preview, Comment Apr 22, 2026 2:24pm

Request Review

Comment thread pkg/repository/match.go
m.l.Error().Err(err).Msgf("failed to unmarshal desired worker labels for dag id %d and dag inserted at %s", dagData.DagID, dagData.DagInsertedAt.Time)
}
}
dagIdsToDesiredWorkerLabels[dagData.DagID] = dagData.DesiredWorkerLabels
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll be able to remove this in a little bit once all the existing dags are cut over

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds webhook-level control over whether the created event is echoed back in webhook HTTP responses, propagates triggering event metadata through tasks into worker context across SDKs, and refactors match/label storage to fix internal DAG label matching behavior.

Changes:

  • Added return_event_as_response_payload to incoming webhooks, wired through API/SDKs/UI, and used to optionally omit the event from webhook responses.
  • Added triggering_event_external_id / triggering_event_key to tasks (core + OLAP) and propagated through dispatcher contracts into worker contexts (Go/TS/Python).
  • Refactored match/DAG desired-worker-label handling to store/carry label payloads via v1_match.trigger_desired_worker_labels.

Reviewed changes

Copilot reviewed 50 out of 52 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
api/v1/server/handlers/v1/webhooks/create.go Sets the new webhook response toggle during webhook creation.
api/v1/server/handlers/v1/webhooks/receive.go Uses the stored toggle to decide whether to include the created event in the HTTP response.
api/v1/server/handlers/v1/webhooks/update.go Allows updating the new webhook response toggle.
pkg/repository/webhooks.go Persists the new webhook toggle via sqlc queries.
frontend/app/src/pages/main/v1/webhooks/index.tsx Adds UI switches in create/edit modals and sends the toggle to the API.
sql/schema/v1-core.sql, sql/schema/v1-olap.sql, migration Adds DB columns for webhook toggle + triggering event fields + match label storage.
pkg/repository/trigger.go, pkg/repository/task.go, pkg/repository/match.go Propagates triggering event metadata into matches/tasks and adjusts desired-label handling.
api-contracts/dispatcher/dispatcher.proto + generated TS/Python Adds triggering event fields to dispatcher AssignedAction and propagates into SDK contexts.
sdks/python/poetry.lock Updates Python lockfile (but appears generated with a mismatched Poetry version).
Comments suppressed due to low confidence (1)

api/v1/server/handlers/v1/webhooks/update.go:47

  • V1WebhookUpdate mutates a webhook but does not emit an analytics event (unlike create/delete). Since this PR adds a new user-controlled behavior flag, it would be useful to instrument webhook updates (and include a low-cardinality property like return_event_as_response_payload) so usage can be tracked.
func (w *V1WebhooksService) V1WebhookUpdate(ctx echo.Context, request gen.V1WebhookUpdateRequestObject) (gen.V1WebhookUpdateResponseObject, error) {
	webhook := ctx.Get("v1-webhook").(*sqlcv1.V1IncomingWebhook)

	opts := repository.UpdateWebhookOpts{
		EventKeyExpression:           request.Body.EventKeyExpression,
		ScopeExpression:              request.Body.ScopeExpression,
		ReturnEventAsResponsePayload: request.Body.ReturnEventAsResponsePayload,
	}

	if request.Body.StaticPayload != nil {
		payloadBytes, err := json.Marshal(request.Body.StaticPayload)
		if err != nil {
			return gen.V1WebhookUpdate400JSONResponse(apierrors.NewAPIErrors("failed to marshal static payload")), nil
		}
		opts.StaticPayload = payloadBytes
	}

	webhook, err := w.config.V1.Webhooks().UpdateWebhook(
		ctx.Request().Context(),
		webhook.TenantID,
		webhook.Name,
		opts,
	)

	if err != nil {
		return gen.V1WebhookUpdate400JSONResponse(apierrors.NewAPIErrors("failed to update webhook")), nil
	}

	transformed := transformers.ToV1Webhook(webhook)

	return gen.V1WebhookUpdate200JSONResponse(
		transformed,
	), nil

Comment thread pkg/repository/task.go Outdated
Comment thread api/v1/server/handlers/v1/webhooks/create.go
Comment thread api/v1/server/handlers/v1/webhooks/create.go
Comment thread api/v1/server/handlers/v1/webhooks/create.go Outdated
Comment thread pkg/repository/webhooks.go
promptless-for-oss pushed a commit to Promptless/oss-contrib-hatchet-dev-hatchet that referenced this pull request Apr 15, 2026
…roperties

- Add Return Event as Response Payload toggle documentation to webhooks page
- Add triggering_event_id and triggering_event_key properties to Python Context reference
- Add triggeringEventId() and triggeringEventKey() methods to TypeScript Context reference

Related to PR hatchet-dev#3625
@promptless-for-oss
Copy link
Copy Markdown

Promptless prepared a documentation update related to this change.

Added documentation for the new webhook response toggle (to control whether triggered events are returned in webhook HTTP responses) and the new context properties (triggering_event_id/triggering_event_key in Python, triggeringEventId()/triggeringEventKey() in TypeScript).

Review: Document webhook response toggle and triggering event context properties

Copy link
Copy Markdown
Member

@mnafees mnafees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall; one small comment

action.ChildWorkflowKey = &key
}

if task.TriggeringEventExternalID != nil {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we worried about this being a uuid.Nil by any chance apart from being a nil pointer?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine, pretty sure I've caught all of these at this point

@mrkaye97 mrkaye97 merged commit 5e1fabb into main Apr 22, 2026
68 of 69 checks passed
@mrkaye97 mrkaye97 deleted the mk/dont-send-back-full-webhook-payload branch April 22, 2026 14:36
wsehl pushed a commit to wsehl/hatchet that referenced this pull request Apr 23, 2026
…s matches (hatchet-dev#3625)

* feat: add boolean flag for whether or not to return the event as the response payload

* feat: add field to indicate whether or not to return the event

* fix: wire up receive api

* feat: more columns for event trigger idea

* feat: start wiring up queries

* feat: internal wiring

* fix: matches, more wiring

* fix: simplify query

* fix: more wiring

* fix: clean up dag impl for worker labels too

* fix: wiring, unwind dag changes

* fix: if

* feat: add webhook response switch on fe

* fix: casing

* fix: populator

* feat: add fields to assigned action for trigger

* feat: send trigger data back over the api to the context

* chore: gen py

* feat: wire up context in py

* feat: update webhooks feature client

* feat: ts, go

* chore: lint

* fix: more wiring for replay

* fix: nil handling

* chore: gen

* chore: attempt to fix flaky test

* feat: wire up olap writes

* fix: rm changes on the olap side for now

* fix: improve the `was_triggered_by_event` prop

* chore: gen, fix migration version

* chore: versions, changelogs
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.

4 participants