{"record":{"id":"00d73a230bffd16d","repo":"windmill-labs/windmill","slug":"invalid-note-at-index-index-color-must-be-one","errorCode":null,"errorMessage":"Invalid note at index ${index}: color must be one of ${[...ALLOWED_NOTE_COLORS].join(', ')}","messagePattern":"Invalid note at index (.+?): color must be one of (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/chat/flow/helperUtils.ts","lineNumber":188,"sourceCode":"\t\t}\n\t\tconst n = note as Record<string, unknown>\n\t\tif (typeof n.id !== 'string' || !n.id) {\n\t\t\tthrow new Error(`Invalid note at index ${index}: id must be a non-empty string`)\n\t\t}\n\t\tif (seenIds.has(n.id)) {\n\t\t\tthrow new Error(`Invalid note at index ${index}: duplicate note id \"${n.id}\"`)\n\t\t}\n\t\tseenIds.add(n.id)\n\t\tif (typeof n.text !== 'string') {\n\t\t\tthrow new Error(`Invalid note at index ${index}: text must be a string`)\n\t\t}\n\t\tconst type = n.type ?? 'free'\n\t\tif (type !== 'free' && type !== 'group') {\n\t\t\tthrow new Error(`Invalid note at index ${index}: type must be \"free\" or \"group\"`)\n\t\t}\n\t\tif (n.color !== undefined && n.color !== null) {\n\t\t\tif (typeof n.color !== 'string' || !ALLOWED_NOTE_COLORS.has(n.color)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Invalid note at index ${index}: color must be one of ${[...ALLOWED_NOTE_COLORS].join(', ')}`\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tif (n.position !== undefined && n.position !== null) {\n\t\t\tconst p = n.position as Record<string, unknown>\n\t\t\tif (\n\t\t\t\ttypeof p !== 'object' ||\n\t\t\t\tArray.isArray(n.position) ||\n\t\t\t\ttypeof p.x !== 'number' ||\n\t\t\t\ttypeof p.y !== 'number'\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Invalid note at index ${index}: position must be an object with numeric x and y`\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tif (n.size !== undefined && n.size !== null) {","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/flow/helperUtils.ts#L170-L206","documentation":"Note colors are restricted to the NoteColor palette (yellow, blue, green, purple, pink, orange, red, cyan, lime, gray) because the renderer styles notes by these exact names. A non-string color or a string outside the palette throws this error in validateFlowNotes.","triggerScenarios":"notes: [{ id: 'n1', text: 'x', color: '#fff3cd' }] or color: 'amber' or color: 1 passed to patch_flow_json/set_flow_json.","commonSituations":"An LLM agent outputs hex codes or CSS color names outside the palette; a numeric enum index was passed; colors were copied from another design system's vocabulary.","solutions":["Use one of the palette names exactly: yellow, blue, green, purple, pink, orange, red, cyan, lime, gray","Omit color (undefined/null) to let the validator fill in the default note color","Map hex/CSS colors to the nearest palette name before sending"],"exampleFix":"// before\nnotes: [{ id: 'n1', text: 'x', color: '#FF0000' }]\n// after\nnotes: [{ id: 'n1', text: 'x', color: 'red' }]","handlingStrategy":"validation","validationCode":"const ALLOWED = ['yellow','blue','green','purple','pink','orange','red','cyan','lime','gray'];\nnotes.forEach((n, i) => {\n  if (n.color != null && !ALLOWED.includes(n.color)) throw new Error(`notes[${i}].color \"${n.color}\" not in palette`);\n});","typeGuard":"function isNoteColor(c: unknown): c is NoteColor {\n  return typeof c === 'string' && (Object.values(NoteColor) as string[]).includes(c);\n}","tryCatchPattern":"try {\n  validateFlowNotes(rawNotes, moduleIds);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('color must be one of')) {\n    // retry with color omitted to accept the default\n  } else throw e;\n}","preventionTips":["Restrict color choices to the ten palette names in any tooling that builds notes","Omit color to get DEFAULT_NOTE_COLOR filled in automatically","Translate hex/CSS colors to the nearest palette name at payload-construction time"],"tags":["validation","flow-notes","enum-value","color"],"backgroundTag":"invalid-enum-value","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"}