Repository navigation
feat: forward selected webhook headers to DAG runs - #2050
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughAdds per‑DAG Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client
participant Frontend as FrontendAPI
participant Middleware as Middleware (WebhookRequestContextMiddleware)
participant Handler as TriggerWebhook Handler
participant Spec as DAG Spec/Loader
participant Queue as Queue
Client->>Frontend: POST /api/v1/webhooks/{id} (body + headers)
Frontend->>Middleware: pass request
Middleware-->>Frontend: attach raw body + normalized headers to context
Frontend->>Handler: call TriggerWebhook with ctx
Handler->>Spec: load DAG and webhook.forward_headers
Handler->>Handler: marshal payload -> WEBHOOK_PAYLOAD
Handler->>Handler: select/filter headers -> marshal -> WEBHOOK_HEADERS
Handler->>Queue: enqueue DAG run with runtime params
Queue-->>Client: respond with dag-run ID
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@api/v1/api.yaml`:
- Around line 3860-3863: The documentation claims selected request headers are
passed as the WEBHOOK_HEADERS environment variable when webhook.forward_headers
is configured, but it omits that the Authorization header is explicitly blocked;
update the sentence describing webhook.forward_headers/WEBHOOK_HEADERS to add a
clear caveat that the Authorization header will never be forwarded (i.e.,
Authorization is always excluded from WEBHOOK_HEADERS).
In `@internal/core/spec/dag.go`:
- Around line 884-901: The webhook forward header validation currently only
checks for empty strings and rejects "Authorization" but accepts invalid HTTP
header token names; update the parsing/validation in the block handling
d.Webhook.ForwardHeaders (where core.NormalizeWebhookForwardHeader and
core.IsDeniedWebhookForwardHeader are used) to additionally validate that the
normalized header matches the RFC9110 token grammar (tchar set: alphanumerics
and !#$%&'*+-.^_`|~) and return a core.NewValidationError (same pattern as
existing errors) when it does not, before appending to headers; implement the
token check either by calling or adding a helper like core.IsValidHeaderToken
and use it in this loop to reject entries such as "my header".
In `@internal/core/spec/key_hints.go`:
- Line 34: Add a unit test that exercises the key hint lookup for the
"forwardHeaders" → "webhook.forward_headers" mapping found in key_hints.go:
create a webhook config using the camelCase key "forwardHeaders" (instead of
"forward_headers"), run the same validation/parse path used by existing webhook
tests, and assert that the returned error message includes the hint recommending
"webhook.forward_headers"; this ensures the mapping for the symbol
"forwardHeaders" in key_hints.go is covered and the suggestion text appears in
the error output.
In `@ui/src/features/dags/components/dag-details/WebhookTab.tsx`:
- Around line 982-992: The copy mistakenly suggests webhook.forward_headers can
be set "in the DAG or base config" while this feature is DAG-scoped; update the
text in WebhookTab (the list item referring to webhook.forward_headers and
WEBHOOK_HEADERS) to remove "or base config" and explicitly state that
webhook.forward_headers is configured in the DAG only (or otherwise reword to
indicate DAG scope) so it doesn't imply a base-config option.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c8ab9137-e26d-44b7-b62b-6296b26c6d3b
📒 Files selected for processing (21)
api/v1/api.gen.goapi/v1/api.yamlinternal/cmn/schema/dag.schema.jsoninternal/core/dag.gointernal/core/spec/dag.gointernal/core/spec/dag_params_runtime.gointernal/core/spec/dag_test.gointernal/core/spec/key_hints.gointernal/core/spec/loader.gointernal/core/spec/loader_test.gointernal/core/spec/runtime_params_test.gointernal/core/webhook.gointernal/core/webhook_test.gointernal/service/frontend/api/v1/api.gointernal/service/frontend/api/v1/export_test.gointernal/service/frontend/api/v1/webhook_helpers_test.gointernal/service/frontend/api/v1/webhook_middleware.gointernal/service/frontend/api/v1/webhooks.gointernal/service/frontend/api/v1/webhooks_test.goui/src/api/v1/schema.tsui/src/features/dags/components/dag-details/WebhookTab.tsx
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/cmn/fileutil/fileutil.go`:
- Around line 214-221: Trim dagName into a local variable first and treat a
whitespace-only value as empty: after computing trimmed :=
strings.TrimSpace(dagName) set patternName to a safe fallback (e.g., "dag" or
another default) when trimmed == "" otherwise set patternName =
filepath.Base(trimmed) and then remove YAML extension as you already do; finally
use TruncString(patternName, maxTempPrefix) to build pattern — this ensures
patternName never contains only spaces and avoids unsafe prefixes when creating
pattern.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 644c3573-6c55-48e1-b829-80240ae3654e
📒 Files selected for processing (3)
internal/cmn/fileutil/fileutil.gointernal/cmn/fileutil/fileutil_test.gointernal/service/frontend/api/v1/webhooks_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
- internal/service/frontend/api/v1/webhooks_test.go
Closes #2037
Summary
webhook.forward_headerssupport and expose forwarded headers asWEBHOOK_HEADERSAuthorizationblockedWhy
Validation
go test ./internal/core ./internal/core/spec ./internal/service/frontend/api/v1 -count=1pnpm --dir ui typecheckSummary by CodeRabbit
New Features
Documentation