Skip to content

fix: make external webhook trigger creation atomic#349

Merged
marccampbell merged 2 commits into
mainfrom
feat/atomic-external-webhook
Jun 4, 2026
Merged

fix: make external webhook trigger creation atomic#349
marccampbell merged 2 commits into
mainfrom
feat/atomic-external-webhook

Conversation

@elasticclaw-marc

Copy link
Copy Markdown
Contributor

Fixes #299

Replace the non-atomic findClawForExternalTrigger check with the existing factory_triggers claim/complete mechanism. This prevents concurrent webhook deliveries from racing and creating duplicate claws for the same factory/external_trigger_id.

Changes

  • processExternalEvent: use claimFactoryTrigger before createClawForExternalEvent
  • createClawForExternalEvent: return (clawID, error) instead of just error
  • Remove findClawForExternalTrigger (non-atomic, now unnecessary)
  • Treat duplicate claims as idempotent success (already claimed = no error)
  • Add concurrent delivery regression test

Verification

  • go build ./pkg/hub/... passes
  • go test ./pkg/hub/... passes
  • go test -tags integration -run TestExternalWebhook -count=1 -v ./pkg/hub/... passes
  • All existing factory trigger tests pass

Replace the non-atomic findClawForExternalTrigger check with the existing
factory_triggers claim/complete mechanism. This prevents concurrent webhook
deliveries from racing and creating duplicate claws for the same
factory/external_trigger_id.

Changes:
- processExternalEvent: use claimFactoryTrigger before createClawForExternalEvent
- createClawForExternalEvent: return (clawID, error) instead of just error
- Remove findClawForExternalTrigger (non-atomic, now unnecessary)
- Treat duplicate claims as idempotent success (already claimed = no error)
- Add concurrent delivery regression test

Fixes #299
@greptile-apps

greptile-apps Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix: make external webhook trigger creat..." | Re-trigger Greptile

Comment thread pkg/hub/external_webhook.go Outdated
@greptile-apps

greptile-apps Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Reviews (2): Last reviewed commit: "Scope external trigger claim cleanup" | Re-trigger Greptile

@marccampbell marccampbell merged commit 4ee9517 into main Jun 4, 2026
4 checks 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.

Make external webhook trigger creation atomic

1 participant