Skip to content

feat(github): deliver webhook events to Mesh via trigger callbacks - #332

Merged
viktormarinho merged 4 commits into
mainfrom
viktormarinho/trigger-callback
Mar 27, 2026
Merged

viktormarinho merged 4 commits into
mainfrom
viktormarinho/trigger-callback

Conversation

@viktormarinho

@viktormarinho viktormarinho commented Mar 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Replace the manual in-memory trigger store, tool definitions, and webhook callback logic with the @decocms/runtime triggers SDK (createTriggers, triggers.tools(), triggers.notify())
  • Trigger definitions now use Zod schemas for params validation instead of raw paramsSchema objects
  • Optional persistent storage via StudioKV when MESH_URL and MESH_API_KEY are set
  • Bump @decocms/runtime to ^1.3.0 and @decocms/bindings to ^1.4.0

What changed

trigger-store.ts

Replaced ~140 lines of manual trigger config management (in-memory maps, credential storage, matching logic) with a single createTriggers() call that handles all of it internally.

tools/index.ts

Removed manual TRIGGER_LIST and TRIGGER_CONFIGURE tool creation. Now uses triggers.tools() which returns the same tools from the SDK.

webhook.ts

Replaced manual hasMatchingTrigger + getCallbackCredentials + raw fetch callback with a single triggers.notify() call. The SDK handles credential lookup and delivery internally.

Test plan

  • Verify trigger list and configure tools still appear in the MCP tool list
  • Configure a trigger via TRIGGER_CONFIGURE and confirm it persists
  • Send a test webhook and verify triggers.notify() delivers the callback
  • Test with and without MESH_URL/MESH_API_KEY env vars

Store callback URL and token from TRIGGER_CONFIGURE, then POST event
payloads to Mesh's trigger-callback endpoint on webhook match.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="github/server/webhook.ts">

<violation number="1" location="github/server/webhook.ts:66">
P1: Non-2xx callback responses are treated as success because only rejected fetches are caught; failed deliveries (e.g., 401/500) will not be logged.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread github/server/webhook.ts Resolved
… implementation

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 4 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="github/server/lib/trigger-store.ts">

<violation number="1" location="github/server/lib/trigger-store.ts:14">
P2: The trigger definitions list drops the previously supported "github.pull_request.review_requested" and "github.release.published" events. Existing automations for those events will stop being configurable or matched after this change.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

return false;
}
export const triggers = createTriggers({
definitions: [

@cubic-dev-ai cubic-dev-ai Bot Mar 27, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: The trigger definitions list drops the previously supported "github.pull_request.review_requested" and "github.release.published" events. Existing automations for those events will stop being configurable or matched after this change.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At github/server/lib/trigger-store.ts, line 14:

<comment>The trigger definitions list drops the previously supported "github.pull_request.review_requested" and "github.release.published" events. Existing automations for those events will stop being configurable or matched after this change.</comment>

<file context>
@@ -1,138 +1,106 @@
-  return callbackCredentials.get(connectionId);
-}
+export const triggers = createTriggers({
+  definitions: [
+    {
+      type: "github.push",
</file context>
Fix with Cubic

viktormarinho and others added 2 commits March 27, 2026 17:08
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@viktormarinho
viktormarinho merged commit 459b4f1 into main Mar 27, 2026
1 of 2 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.

1 participant