Fix: Webhook responses, event info on context, internal fix for labels matches#3625
Fix: Webhook responses, event info on context, internal fix for labels matches#3625
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| 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 |
There was a problem hiding this comment.
we'll be able to remove this in a little bit once all the existing dags are cut over
There was a problem hiding this comment.
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_payloadto incoming webhooks, wired through API/SDKs/UI, and used to optionally omit the event from webhook responses. - Added
triggering_event_external_id/triggering_event_keyto 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
V1WebhookUpdatemutates 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 likereturn_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
…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 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 ( Review: Document webhook response toggle and triggering event context properties |
mnafees
left a comment
There was a problem hiding this comment.
LGTM overall; one small comment
| action.ChildWorkflowKey = &key | ||
| } | ||
|
|
||
| if task.TriggeringEventExternalID != nil { |
There was a problem hiding this comment.
Are we worried about this being a uuid.Nil by any chance apart from being a nil pointer?
There was a problem hiding this comment.
I think it's fine, pretty sure I've caught all of these at this point
…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
Description
Fixes a couple things:
triggering_event_idandtriggering_event_key) to be able to see what event triggered any given task, if anyWebhooks ui:
update:

create:

Type of change