Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix(agent): preserve and resolve webhook header fields (#20696)

Guofang.Tang89ca7f7b3886
diff --git a/internal/agent/component/begin.go b/internal/agent/component/begin.go
index a5dd65a82a..18c9884058 100644
--- a/internal/agent/component/begin.go
+++ b/internal/agent/component/begin.go
@@ -67,7 +67,8 @@ func (b *BeginComponent) Name() string { return b.name }
// Invoke writes inputs["query"] and (when present) inputs["user_id"] into
// the shared *CanvasState.Sys namespace, then returns the input map as
-// outputs unchanged. The input map is shallow-copied to avoid aliasing
+// outputs, exposing structured webhook sections at top level.
+// The input map is shallow-copied to avoid aliasing
// surprises across concurrent goroutines that share an inputs map.
func (b *BeginComponent) Invoke(ctx context.Context, db *gorm.DB, inputs map[string]any) (map[string]any, error) {
state, err := runtime.GetStateFromContext(ctx)
@@ -121,6 +122,15 @@ func (b *BeginComponent) Invoke(ctx context.Context, db *gorm.DB, inputs map[str
out[field] = value
}
}
+ // Webhook fields are public Begin outputs referenced as [email protected],
+ // [email protected] and [email protected] by the workflow editor.
+ if payload, ok := inputs["webhook_payload"].(map[string]any); ok {
+ for _, section := range []string{"query", "headers", "body"} {
+ if fields, ok := payload[section].(map[string]any); ok {
+ out[section] = maps.Clone(fields)
+ }
+ }
+ }
return out, nil
}
@@ -204,10 +214,12 @@ func (b *BeginComponent) Inputs() map[string]string {
}
}
-// Outputs returns the same keys as Inputs (Begin is a passthrough).
+// Outputs describes the entry inputs and structured webhook request sections.
func (b *BeginComponent) Outputs() map[string]string {
return map[string]string{
- "query": "Query string (passthrough).",
+ "query": "Query string, or structured query fields for webhook runs.",
+ "headers": "Schema-extracted webhook headers.",
+ "body": "Schema-extracted webhook body fields.",
"user_id": "User id, if provided (passthrough).",
"webhook_payload": "Webhook request payload, if provided (passthrough; also written to state.Sys[webhook_payload]).",
"inputs": "Raw inputs map (passthrough).",
diff --git a/internal/agent/component/begin_test.go b/internal/agent/component/begin_test.go
index 370abfb65d..73e45fbec4 100644
--- a/internal/agent/component/begin_test.go
+++ b/internal/agent/component/begin_test.go
@@ -257,6 +257,19 @@ func TestBegin_InjectsWebhookPayload(t *testing.T) {
if outPayload, _ := out["webhook_payload"].(map[string]any); !reflect.DeepEqual(outPayload, payload) {
t.Errorf("outputs[webhook_payload] mismatch:\n got %v\n want %v", outPayload, payload)
}
+ for key, value := range out {
+ state.SetVar("Begin", key, value)
+ }
+ for _, tt := range []struct{ ref, want string }{
+ {"[email protected]", "abc"},
+ {"[email protected]", "hello"},
+ {"[email protected]", "v"},
+ } {
+ got, err := canvas.ResolveTemplate("{{"+tt.ref+"}}", state)
+ if err != nil || got != tt.want {
+ t.Errorf("resolve %s = %q, %v; want %q", tt.ref, got, err, tt.want)
+ }
+ }
}
// TestBegin_AbsentWebhookPayload confirms that the chat path (no
diff --git a/internal/handler/agent_webhook_schema.go b/internal/handler/agent_webhook_schema.go
index 09b647a6cb..c6665b3827 100644
--- a/internal/handler/agent_webhook_schema.go
+++ b/internal/handler/agent_webhook_schema.go
@@ -18,11 +18,9 @@ package handler
// Webhook schema helpers.
//
-// These mirror api/apps/restful_apis/agent_api.py:1896-2051 (extract_by_schema,
-// default_for_type, auto_cast_value, validate_type) from the Python
-// webhook handler. The Go port preserves the Python semantics exactly:
-// required fields raise; optional fields get a type-based default;
-// type coercion runs before validation.
+// Required fields must be present; optional fields get a type-based default.
+// Type coercion runs before validation. Header names are matched without
+// regard to case, while query and body fields use their exact names.
//
// Edge cases preserved:
// - "file" type maps to []any (a list of parsed file descriptors).
@@ -201,6 +199,15 @@ func extractBySchema(data map[string]any, schema map[string]any, name string) (m
if schema == nil {
schema = map[string]any{}
}
+ // HTTP header names are case-insensitive; retain the schema's spelling
+ // in the output so downstream references keep their configured keys.
+ if name == "headers" {
+ headers := make(map[string]any, len(data))
+ for key, value := range data {
+ headers[strings.ToLower(key)] = value
+ }
+ data = headers
+ }
props, _ := schema["properties"].(map[string]any)
required := stringSlice(schema["required"])
@@ -210,17 +217,19 @@ func extractBySchema(data map[string]any, schema map[string]any, name string) (m
for field, rawSchema := range props {
fieldSchema, _ := rawSchema.(map[string]any)
fieldType, _ := fieldSchema["type"].(string)
+ lookupKey := field
+ if name == "headers" {
+ lookupKey = strings.ToLower(field)
+ }
+ raw, present := data[lookupKey]
// 1. Required field missing → error (python agent_api.py:1913).
isRequired := contains(required, field)
- if isRequired {
- if _, ok := data[field]; !ok {
- return nil, fmt.Errorf("%s missing required field: %s", name, field)
- }
+ if isRequired && !present {
+ return nil, fmt.Errorf("%s missing required field: %s", name, field)
}
// 2. Optional → default value.
- raw, present := data[field]
if !present {
out[field] = defaultForType(fieldType)
continue
diff --git a/internal/handler/agent_webhook_schema_test.go b/internal/handler/agent_webhook_schema_test.go
index 439d6a7ac7..8e308abad0 100644
--- a/internal/handler/agent_webhook_schema_test.go
+++ b/internal/handler/agent_webhook_schema_test.go
@@ -17,10 +17,52 @@
package handler
import (
+ "net/http/httptest"
"strings"
"testing"
)
+// TestExtractBySchemaHeaderNames keeps HTTP lookup case-insensitive without changing output keys.
+func TestExtractBySchemaHeaderNames(t *testing.T) {
+ for _, field := range []string{"x-request-id", "X-Request-ID", "X-REQUEST-ID"} {
+ t.Run(field, func(t *testing.T) {
+ request := httptest.NewRequest("POST", "/", nil)
+ request.Header.Set("x-request-id", "request-123")
+ data := map[string]any{}
+ for key, values := range request.Header {
+ data[key] = values[0]
+ }
+ schema := map[string]any{
+ "properties": map[string]any{field: map[string]any{"type": "string"}},
+ "required": []string{field},
+ }
+ got, err := extractBySchema(data, schema, "headers")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(got) != 1 || got[field] != "request-123" {
+ t.Fatalf("extracted headers = %#v, want configured key %q", got, field)
+ }
+ })
+ }
+}
+
+// TestExtractBySchemaCaseSensitiveSections preserves case-sensitive body and query fields.
+func TestExtractBySchemaCaseSensitiveSections(t *testing.T) {
+ for _, section := range []string{"query", "body"} {
+ t.Run(section, func(t *testing.T) {
+ schema := map[string]any{
+ "properties": map[string]any{"ID": map[string]any{"type": "string"}},
+ "required": []string{"ID"},
+ }
+ _, err := extractBySchema(map[string]any{"id": "123"}, schema, section)
+ if err == nil || !strings.Contains(err.Error(), "missing required field") {
+ t.Fatalf("error = %v, want missing required field", err)
+ }
+ })
+ }
+}
+
// TestExtractBySchema_RequiredMissing pins the required-field-missing
// branch (mirrors python agent_api.py:1913).
func TestExtractBySchema_RequiredMissing(t *testing.T) {
diff --git a/internal/handler/agent_webhook_test.go b/internal/handler/agent_webhook_test.go
index b95674159d..4dc21a747f 100644
--- a/internal/handler/agent_webhook_test.go
+++ b/internal/handler/agent_webhook_test.go
@@ -157,6 +157,30 @@ func errBody(t *testing.T, body []byte) (int, string) {
// ---------- Phase 1: canvas loading / DataFlow rejection ----------
+// TestWebhookHeaderSchemaAcceptsMixedCase verifies real request parsing and schema validation before dispatch.
+func TestWebhookHeaderSchemaAcceptsMixedCase(t *testing.T) {
+ for _, path := range []string{"/api/v1/agents/c1/webhook", "/api/v1/agents/c1/webhook/test"} {
+ t.Run(path, func(t *testing.T) {
+ cv := makeWebhookCanvas("c1", "u-1", "Webhook", map[string]any{
+ "execution_mode": "Streaming",
+ "schema": map[string]any{"headers": map[string]any{
+ "properties": map[string]any{"x-request-id": map[string]any{"type": "string"}},
+ "required": []string{"x-request-id"},
+ }},
+ })
+ loader := &fakeCanvasLoader{canvas: cv}
+ h := &AgentHandler{loader: loader}
+ h.webhookTraceAppender = func(context.Context, string, time.Time, canvas.RunEvent) {}
+ c, w := webhookCtx("POST", path, `{}`, "application/json")
+ c.Request.Header.Set("X-Request-ID", "request-123")
+ h.Webhook(c)
+ if w.Code != http.StatusOK || loader.runCalls.Load() != 1 || !strings.Contains(w.Body.String(), `"success":true`) {
+ t.Fatalf("status=%d runs=%d response=%s", w.Code, loader.runCalls.Load(), w.Body.String())
+ }
+ })
+ }
+}
+
// TestWebhook_RejectsUnknownCanvas pins the 102 "Canvas not found."
// envelope when LoadCanvasByID returns ErrUserCanvasNotFound. This is
// the deliberate divergence from mapAgentError (which would surface 103).
diff --git a/internal/handler/agent_webhook_workflow_test.go b/internal/handler/agent_webhook_workflow_test.go
new file mode 100644
index 0000000000..37ecb13c98
--- /dev/null
+++ b/internal/handler/agent_webhook_workflow_test.go
@@ -0,0 +1,96 @@
+// Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package handler
+
+import (
+ "context"
+ "encoding/json"
+ "testing"
+ "time"
+
+ "ragflow/internal/agent/canvas"
+)
+
+// webhookWorkflowLoader runs real canvas nodes while replacing database-backed canvas loading.
+type webhookWorkflowLoader struct{ *fakeCanvasLoader }
+
+// RunAgentWithWebhook forwards the cleaned HTTP payload into a compiled Begin-to-Message workflow.
+func (f *webhookWorkflowLoader) RunAgentWithWebhook(ctx context.Context, _, _ string, payload map[string]any) (<-chan canvas.RunEvent, error) {
+ raw, err := json.Marshal(f.canvas.DSL)
+ if err != nil {
+ return nil, err
+ }
+ var workflow canvas.Canvas
+ if err := json.Unmarshal(raw, &workflow); err != nil {
+ return nil, err
+ }
+ compiled, err := canvas.Compile(ctx, &workflow)
+ if err != nil {
+ return nil, err
+ }
+ state := canvas.NewCanvasState("header-run", "header-session")
+ ctx = canvas.WithState(ctx, state)
+ if _, err := compiled.Workflow.Invoke(ctx, map[string]any{"query": "", "webhook_payload": payload}); err != nil {
+ return nil, err
+ }
+ content, err := state.GetVar("message@content")
+ if err != nil {
+ return nil, err
+ }
+ data, err := json.Marshal(map[string]any{"content": content})
+ if err != nil {
+ return nil, err
+ }
+ events := make(chan canvas.RunEvent, 1)
+ events <- canvas.RunEvent{Type: "message", Data: string(data)}
+ close(events)
+ return events, nil
+}
+
+// TestWebhookHeaderReachesDownstreamMessage covers HTTP parsing, schema extraction, Begin outputs and Message resolution.
+func TestWebhookHeaderReachesDownstreamMessage(t *testing.T) {
+ for _, field := range []string{"x-request-id", "X-Request-ID", "request_id"} {
+ t.Run(field, func(t *testing.T) {
+ cv := makeWebhookCanvas("c1", "u-1", "Webhook", map[string]any{
+ "execution_mode": "Streaming",
+ "schema": map[string]any{"headers": map[string]any{
+ "properties": map[string]any{field: map[string]any{"type": "string"}},
+ "required": []any{field},
+ }},
+ })
+ components := cv.DSL["components"].(map[string]any)
+ components["begin"].(map[string]any)["downstream"] = []string{"message"}
+ components["message"] = map[string]any{
+ "obj": map[string]any{"component_name": "Message", "params": map[string]any{"content": "{{begin@headers." + field + "}}"}},
+ "upstream": []string{"begin"},
+ }
+ h := &AgentHandler{loader: &webhookWorkflowLoader{&fakeCanvasLoader{canvas: cv}}}
+ h.webhookTraceAppender = func(context.Context, string, time.Time, canvas.RunEvent) {}
+ c, w := webhookCtx("POST", "/api/v1/agents/c1/webhook/test", `{}`, "application/json")
+ c.Request.Header.Set(field, "request-123")
+ h.Webhook(c)
+ var result struct {
+ Message string `json:"message"`
+ Success bool `json:"success"`
+ }
+ if err := json.Unmarshal(w.Body.Bytes(), &result); err != nil {
+ t.Fatal(err)
+ }
+ if !result.Success || result.Message != "request-123" {
+ t.Fatalf("downstream response = %s, want original header value", w.Body.String())
+ }
+ })
+ }
+}
diff --git a/web/src/pages/agent/form/begin-form/__tests__/use-watch-change.test.tsx b/web/src/pages/agent/form/begin-form/__tests__/use-watch-change.test.tsx
new file mode 100644
index 0000000000..5d3a8f624b
--- /dev/null
+++ b/web/src/pages/agent/form/begin-form/__tests__/use-watch-change.test.tsx
@@ -0,0 +1,36 @@
+import { renderHook } from '@testing-library/react';
+import { useForm } from 'react-hook-form';
+import { useWatchFormChange } from '../use-watch-change';
+
+const mockUpdateNodeForm = jest.fn();
+
+jest.mock('../../../store', () => ({
+ __esModule: true,
+ default: (selector: any) => selector({ updateNodeForm: mockUpdateNodeForm }),
+}));
+
+test('exposes webhook section fields as Begin output references', () => {
+ renderHook(() => {
+ const form = useForm<Record<string, any>>({
+ defaultValues: {
+ mode: 'Webhook',
+ schema: {
+ headers: [{ key: 'x-request-id', type: 'string', required: true }],
+ query: [{ key: 'q', type: 'string', required: false }],
+ body: [{ key: 'value', type: 'string', required: false }],
+ },
+ },
+ });
+ useWatchFormChange('Begin', form);
+ });
+ expect(mockUpdateNodeForm).toHaveBeenCalledWith(
+ 'Begin',
+ expect.objectContaining({
+ outputs: {
+ 'headers.x-request-id': { type: 'string' },
+ 'query.q': { type: 'string' },
+ 'body.value': { type: 'string' },
+ },
+ }),
+ );
+});
diff --git a/web/src/pages/agent/form/begin-form/schema.ts b/web/src/pages/agent/form/begin-form/schema.ts
index febf0d84d8..e5c374abd1 100644
--- a/web/src/pages/agent/form/begin-form/schema.ts
+++ b/web/src/pages/agent/form/begin-form/schema.ts
@@ -3,14 +3,19 @@ import { countBy } from 'lodash';
import { z } from 'zod';
import { isValidIpOrCidr } from './utils';
+/** Rejects duplicate field names, ignoring case only for HTTP headers. */
function validateUniqueKeys(
items: Array<{ key: string }>,
ctx: z.RefinementCtx,
+ ignoreCase = false,
) {
- const keyCounts = countBy(items, 'key');
+ const keyCounts = countBy(items, (item) =>
+ ignoreCase ? item.key.toLowerCase() : item.key,
+ );
items.forEach((item, index) => {
- if (item.key && keyCounts[item.key] > 1) {
+ const key = ignoreCase ? item.key.toLowerCase() : item.key;
+ if (key && keyCounts[key] > 1) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
path: [index, 'key'],
@@ -20,15 +25,31 @@ function validateUniqueKeys(
});
}
+const WebhookParameterSchema = z.object({
+ key: z.string().trim().min(1, 'The key is required!'),
+ type: z.string(),
+ required: z.boolean(),
+});
+
const WebhookParametersSchema = z
+ .array(WebhookParameterSchema)
+ .superRefine(validateUniqueKeys)
+ .optional();
+
+const WebhookHeadersSchema = z
.array(
- z.object({
- key: z.string().trim().min(1, 'The key is required!'),
- type: z.string(),
- required: z.boolean(),
+ WebhookParameterSchema.extend({
+ key: z
+ .string()
+ .trim()
+ .min(1, 'The key is required!')
+ .regex(
+ /^[0-9a-zA-Z_-]+$/,
+ 'Header names may contain only letters, digits, underscores, and hyphens.',
+ ),
}),
)
- .superRefine(validateUniqueKeys)
+ .superRefine((items, ctx) => validateUniqueKeys(items, ctx, true))
.optional();
export const BeginFormSchema = z.object({
@@ -83,7 +104,7 @@ export const BeginFormSchema = z.object({
schema: z
.object({
query: WebhookParametersSchema,
- headers: WebhookParametersSchema,
+ headers: WebhookHeadersSchema,
body: WebhookParametersSchema,
})
.optional(),
diff --git a/web/src/pages/agent/form/begin-form/webhook/__tests__/request-schema.test.tsx b/web/src/pages/agent/form/begin-form/webhook/__tests__/request-schema.test.tsx
new file mode 100644
index 0000000000..9014b1491a
--- /dev/null
+++ b/web/src/pages/agent/form/begin-form/webhook/__tests__/request-schema.test.tsx
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { fireEvent, render, screen } from '@testing-library/react';
+import { FormProvider, useForm } from 'react-hook-form';
+import { WebhookRequestSchema } from '../request-schema';
+import { BeginFormSchema } from '../../schema';
+
+jest.mock('@monaco-editor/react', () => ({ loader: { config: jest.fn() } }));
+jest.mock('react-i18next', () => ({
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+jest.mock('@/components/collapse', () => ({
+ Collapse: ({ children }: { children: React.ReactNode }) => children,
+}));
+jest.mock('@/components/originui/select-with-search', () => {
+ const { forwardRef } = jest.requireActual<typeof import('react')>('react');
+ return { SelectWithSearch: forwardRef(() => null) };
+});
+jest.mock('@/components/ragflow-form', () => {
+ const { Controller } =
+ jest.requireActual<typeof import('react-hook-form')>('react-hook-form');
+ const { cloneElement } = require('react');
+ return {
+ RAGFlowFormItem: ({ name, children }: any) => (
+ <Controller
+ name={name}
+ render={({ field }) =>
+ typeof children === 'function'
+ ? children(field)
+ : cloneElement(children, field)
+ }
+ />
+ ),
+ };
+});
+
+/** Renders one editable field per request section using real form state. */
+function RequestSchemaForm() {
+ const form = useForm({
+ defaultValues: {
+ content_types: 'application/json',
+ schema: {
+ query: [{ key: '', type: 'string', required: false }],
+ headers: [{ key: '', type: 'string', required: false }],
+ body: [{ key: '', type: 'string', required: false }],
+ },
+ },
+ });
+ return (
+ <FormProvider {...form}>
+ <WebhookRequestSchema />
+ </FormProvider>
+ );
+}
+
+test('preserves hyphenated header names and filters unsupported reference characters', () => {
+ render(<RequestSchemaForm />);
+ const [, headerInput] = screen.getAllByRole('textbox');
+ const headerName = 'X-Request-ID_1';
+ fireEvent.change(headerInput, {
+ target: { value: `${headerName}!#$%&'*+.^\u0060|~: ` },
+ });
+ expect(headerInput).toHaveValue(headerName);
+});
+
+test('keeps query and body key filtering unchanged', () => {
+ render(<RequestSchemaForm />);
+ const [queryInput, , bodyInput] = screen.getAllByRole('textbox');
+ for (const input of [queryInput, bodyInput]) {
+ fireEvent.change(input, { target: { value: 'field-name_1' } });
+ expect(input).toHaveValue('fieldname_1');
+ }
+});
+
+test.each(['x-request-id', 'X-Request-ID', 'request_id_1'])(
+ 'accepts referenceable header name %s when saving',
+ (key) => {
+ expect(
+ BeginFormSchema.safeParse({
+ mode: 'Webhook',
+ schema: { headers: [{ key, type: 'string', required: true }] },
+ }).success,
+ ).toBe(true);
+ },
+);
+
+test.each(['x.request.id', 'x+request', 'x!request', 'x request'])(
+ 'rejects unreferenceable header name %s when saving',
+ (key) => {
+ expect(
+ BeginFormSchema.safeParse({
+ mode: 'Webhook',
+ schema: { headers: [{ key, type: 'string', required: true }] },
+ }).success,
+ ).toBe(false);
+ },
+);
+
+test('rejects case-insensitive duplicate header names at both fields', () => {
+ const result = BeginFormSchema.safeParse({
+ mode: 'Webhook',
+ schema: {
+ headers: [
+ { key: 'X-Request-ID', type: 'string', required: true },
+ { key: 'x-request-id', type: 'string', required: false },
+ ],
+ },
+ });
+ expect(result.success).toBe(false);
+ if (!result.success) {
+ expect(result.error.issues.map((issue) => issue.path)).toEqual([
+ ['schema', 'headers', 0, 'key'],
+ ['schema', 'headers', 1, 'key'],
+ ]);
+ }
+});
+
+test.each(['query', 'body'])(
+ 'keeps %s key uniqueness case-sensitive',
+ (section) => {
+ const result = BeginFormSchema.safeParse({
+ mode: 'Webhook',
+ schema: {
+ [section]: [
+ { key: 'ID', type: 'string', required: true },
+ { key: 'id', type: 'string', required: false },
+ ],
+ },
+ });
+ expect(result.success).toBe(true);
+ },
+);
+
+test('preserves the configured spelling of distinct header names', () => {
+ const headers = [
+ { key: 'X-Request-ID', type: 'string', required: true },
+ { key: 'X-Correlation-ID', type: 'string', required: false },
+ ];
+ const result = BeginFormSchema.parse({
+ mode: 'Webhook',
+ schema: { headers },
+ });
+ expect(result.schema?.headers).toEqual(headers);
+});
diff --git a/web/src/pages/agent/form/begin-form/webhook/dynamic-request.tsx b/web/src/pages/agent/form/begin-form/webhook/dynamic-request.tsx
index cc8be825df..21495b3dcc 100644
--- a/web/src/pages/agent/form/begin-form/webhook/dynamic-request.tsx
+++ b/web/src/pages/agent/form/begin-form/webhook/dynamic-request.tsx
@@ -24,8 +24,10 @@ type SelectKeysProps = {
nodeId?: string;
isObject?: boolean;
operatorList: WebhookRequestParameters[];
+ keyInputPattern?: RegExp;
};
+/** Edits request fields, applying the supplied key pattern when filtering names. */
export function DynamicRequest({
name,
label,
@@ -34,6 +36,7 @@ export function DynamicRequest({
operatorField = 'type',
requiredField = 'required',
operatorList,
+ keyInputPattern,
}: SelectKeysProps) {
const form = useFormContext();
@@ -71,7 +74,7 @@ export function DynamicRequest({
<div className="flex-1 space-y-3 min-w-0">
<div className="flex items-start gap-2">
<RAGFlowFormItem name={keyFieldAlias} className="flex-1 ">
- <KeyInput></KeyInput>
+ <KeyInput searchValue={keyInputPattern}></KeyInput>
</RAGFlowFormItem>
<div className="flex h-8 items-center">
<Separator className="w-2" />
diff --git a/web/src/pages/agent/form/begin-form/webhook/request-schema.tsx b/web/src/pages/agent/form/begin-form/webhook/request-schema.tsx
index c6bd41ef74..ce24b24570 100644
--- a/web/src/pages/agent/form/begin-form/webhook/request-schema.tsx
+++ b/web/src/pages/agent/form/begin-form/webhook/request-schema.tsx
@@ -11,6 +11,10 @@ import { useFormContext, useWatch } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import { DynamicRequest } from './dynamic-request';
+// Dots are path separators; other HTTP token punctuation is not supported by variable references.
+const HeaderNameInvalidCharacters = /[^0-9a-zA-Z_-]/g;
+
+/** Configures request fields with header names supported by downstream variable references. */
export function WebhookRequestSchema() {
const { t } = useTranslation();
const form = useFormContext();
@@ -59,6 +63,7 @@ export function WebhookRequestSchema() {
></DynamicRequest>
<DynamicRequest
name="schema.headers"
+ keyInputPattern={HeaderNameInvalidCharacters}
label={t('flow.webhook.headerParameters')}
operatorList={[WebhookRequestParameters.String]}
></DynamicRequest>