{"record":{"id":"556654fd0bbb5717","repo":"windmill-labs/windmill","slug":"invalid-field-id-must-be-expectedid","errorCode":null,"errorMessage":"Invalid ${field}: id must be \"${expectedId}\"","messagePattern":"Invalid (.+?): id must be \"(.+?)\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/chat/flow/core.ts","lineNumber":274,"sourceCode":"\tfield: SpecialFlowModuleField\n): FlowModule | null | undefined {\n\tif (module === undefined || module === null) {\n\t\treturn module\n\t}\n\n\tconst result = flowModuleSchema.safeParse(module)\n\tif (!result.success) {\n\t\tconst errors = result.error.issues.slice(0, 5).map((issue) => {\n\t\t\tconst path = issue.path.length > 0 ? issue.path.join('.') : field\n\t\t\treturn `${path}: ${issue.message}`\n\t\t})\n\t\tthrow new Error(`Invalid ${field}:\\n${errors.join('\\n')}`)\n\t}\n\n\tconst parsedModule = result.data\n\tconst expectedId = specialFlowModuleFields[field]\n\tif (parsedModule.id !== expectedId) {\n\t\tthrow new Error(`Invalid ${field}: id must be \"${expectedId}\"`)\n\t}\n\n\tif (parsedModule.value.type !== 'rawscript' && parsedModule.value.type !== 'script') {\n\t\tthrow new Error(`Invalid ${field}: only \"rawscript\" and \"script\" modules are supported`)\n\t}\n\n\treturn parsedModule\n}\n\nconst patchFlowJsonSchema = z.object({\n\told_string: z.string().min(1).describe('Exact text to find in the current compact flow JSON'),\n\tnew_string: z.string().describe('Replacement JSON text'),\n\treplace_all: z\n\t\t.boolean()\n\t\t.optional()\n\t\t.default(false)\n\t\t.describe(\n\t\t\t'When true, replace every exact match. When false, the search text must match exactly once.'","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/flow/core.ts#L256-L292","documentation":"After schema validation succeeds, validateSpecialFlowModule additionally requires the module's id to equal the fixed expected id for that special field (specialFlowModuleFields[field]). A mismatch throws 'Invalid <field>: id must be \"<expectedId>\"'.","triggerScenarios":"The parsed module is structurally valid but parsedModule.id !== specialFlowModuleFields[field] — e.g. an id like 'my_step' or a duplicate/renamed id where the fixed sentinel id is required.","commonSituations":"Model invented a custom id for the special module; the module was copied from another flow and its id was edited; the caller passed the module into the wrong special field.","solutions":["Set the module's id to the exact expected value reported in the error message.","Ensure you are supplying the module to the correct special field (each field has its own expected id).","Regenerate the flow JSON with the instruction that special modules use fixed sentinel ids."],"exampleFix":"// before\n{ \"id\": \"approve_step\", \"value\": ... }\n// after\n{ \"id\": \"approval\", \"value\": ... }","handlingStrategy":"validation","validationCode":"const expectedId = specialFlowModuleFields[field]\nif (module.id !== expectedId) {\n  module = { ...module, id: expectedId }\n}","typeGuard":"function hasExpectedSpecialId(field: SpecialFlowModuleField, m: { id: string }): boolean {\n  return m.id === specialFlowModuleFields[field]\n}","tryCatchPattern":"try {\n  await tool.updateSpecialModule(field, module)\n} catch (e) {\n  const m = e.message.match(/id must be \"(.+)\"/)\n  if (m) return tool.updateSpecialModule(field, { ...module, id: m[1] })\n  throw e\n}","preventionTips":["Hard-code the sentinel id when constructing special modules; never derive it from user input.","Normalize model-generated ids to the expected sentinel before validating.","Consult specialFlowModuleFields when wiring a special field to its module."],"tags":["flow","validation","id-mismatch"],"backgroundTag":"schema-validation-failed","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}