Skip to content

fix: Webhook fallback body#1668

Merged
yottahmd merged 3 commits intomainfrom
webhook-fallback-body
Feb 13, 2026
Merged

fix: Webhook fallback body#1668
yottahmd merged 3 commits intomainfrom
webhook-fallback-body

Conversation

@yottahmd
Copy link
Copy Markdown
Collaborator

@yottahmd yottahmd commented Feb 13, 2026

Summary by CodeRabbit

  • New Features
    • Webhooks now support arbitrary JSON payloads with intelligent format detection and automatic fallback handling. The system accepts both structured payloads and raw request bodies, seamlessly processing whichever format is provided. This enhancement improves webhook integration flexibility, compatibility, and overall user experience when handling diverse payload submission scenarios.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 13, 2026

📝 Walkthrough

Walkthrough

The changes introduce a webhook raw body middleware that captures the original HTTP request body for POST requests to webhook endpoints. When the webhook handler processes requests, it can now use the captured raw body as a fallback when a structured payload isn't available.

Changes

Cohort / File(s) Summary
Middleware Integration
internal/service/frontend/api/v1/api.go, internal/service/frontend/api/v1/webhook_middleware.go
New middleware WebhookRawBodyMiddleware() added and integrated into API route configuration. Middleware captures raw request body for POST requests matching webhook paths, stores it in request context, and replaces the request body reader for downstream handlers.
Payload Processing
internal/service/frontend/api/v1/webhooks.go
Updated marshalWebhookPayload() to accept context parameter and implement fallback logic: uses structured payload if present, otherwise attempts raw body from context, finally defaults to empty JSON object {}.
Testing & Exports
internal/service/frontend/api/v1/export_test.go, internal/service/frontend/api/v1/webhooks_test.go
Exposed internal functions (MarshalWebhookPayload, IsWebhookTriggerPath, WithRawBody) for testing. Added three new test functions covering path matching validation, payload marshaling with raw body fallback, and end-to-end webhook triggering with arbitrary JSON payloads.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (50 files):

⚔️ api/v1/api.gen.go (content)
⚔️ api/v1/api.yaml (content)
⚔️ internal/agent/api.go (content)
⚔️ internal/agent/bash.go (content)
⚔️ internal/agent/bash_test.go (content)
⚔️ internal/agent/hooks.go (content)
⚔️ internal/agent/hooks_test.go (content)
⚔️ internal/agent/loop.go (content)
⚔️ internal/agent/loop_test.go (content)
⚔️ internal/agent/navigate.go (content)
⚔️ internal/agent/navigate_test.go (content)
⚔️ internal/agent/patch.go (content)
⚔️ internal/agent/patch_test.go (content)
⚔️ internal/agent/session.go (content)
⚔️ internal/agent/system_prompt.go (content)
⚔️ internal/agent/system_prompt.txt (content)
⚔️ internal/agent/system_prompt_test.go (content)
⚔️ internal/agent/types.go (content)
⚔️ internal/auth/role.go (content)
⚔️ internal/auth/role_test.go (content)
⚔️ internal/auth/user_test.go (content)
⚔️ internal/cmn/config/config.go (content)
⚔️ internal/cmn/config/config_test.go (content)
⚔️ internal/service/frontend/api/v1/api.go (content)
⚔️ internal/service/frontend/api/v1/audit.go (content)
⚔️ internal/service/frontend/api/v1/export_test.go (content)
⚔️ internal/service/frontend/api/v1/resources.go (content)
⚔️ internal/service/frontend/api/v1/services.go (content)
⚔️ internal/service/frontend/api/v1/webhooks.go (content)
⚔️ internal/service/frontend/api/v1/webhooks_test.go (content)
⚔️ internal/service/frontend/api/v1/workers.go (content)
⚔️ internal/service/frontend/auth/builtin.go (content)
⚔️ internal/service/frontend/auth/middleware_test.go (content)
⚔️ internal/service/oidcprovision/rolemapper.go (content)
⚔️ internal/service/oidcprovision/rolemapper_test.go (content)
⚔️ internal/service/resource/service.go (content)
⚔️ internal/service/resource/store.go (content)
⚔️ internal/service/resource/store_test.go (content)
⚔️ ui/src/App.tsx (content)
⚔️ ui/src/api/v1/schema.ts (content)
⚔️ ui/src/components/ProtectedRoute.tsx (content)
⚔️ ui/src/contexts/AuthContext.tsx (content)
⚔️ ui/src/features/dashboard/components/MiniResourceChart.tsx (content)
⚔️ ui/src/features/system-status/components/ResourceChart.tsx (content)
⚔️ ui/src/menu.tsx (content)
⚔️ ui/src/pages/api-keys/APIKeyFormModal.tsx (content)
⚔️ ui/src/pages/audit-logs/index.tsx (content)
⚔️ ui/src/pages/system-status/index.tsx (content)
⚔️ ui/src/pages/users/UserFormModal.tsx (content)
⚔️ ui/src/pages/webhooks/index.tsx (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding fallback body handling for webhooks through the new middleware and marshalling logic.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch webhook-fallback-body
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch webhook-fallback-body
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
internal/service/frontend/api/v1/webhook_middleware.go (1)

70-77: isWebhookTriggerPath may match deeper nested paths containing /webhooks/.

Paths like /api/v1/some-other/webhooks/foo would match, though this is unlikely given the current route structure. The consequence is benign (body gets stored in context but never used by non-webhook handlers), so this is fine as-is. Worth noting if routes evolve.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@yottahmd yottahmd merged commit 7755fbb into main Feb 13, 2026
5 checks passed
@yottahmd yottahmd deleted the webhook-fallback-body branch February 13, 2026 16:47
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.19%. Comparing base (d496dde) to head (3303ec1).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1668   +/-   ##
=======================================
  Coverage   70.18%   70.19%           
=======================================
  Files         345      345           
  Lines       38664    38740   +76     
=======================================
+ Hits        27135    27192   +57     
- Misses       9361     9381   +20     
+ Partials     2168     2167    -1     

see 20 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d496dde...3303ec1. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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