{"record":{"id":"0c981746af947e52","repo":"windmill-labs/windmill","slug":"no-user-message-found-at-the-specified-index","errorCode":null,"errorMessage":"No user message found at the specified index","messagePattern":"No user message found at the specified index","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/chat/AIChatManager.svelte.ts","lineNumber":2404,"sourceCode":"\t\t\tthis.contextManager.setAskAiContext(options)\n\t\t}\n\t\tthis.instructions = prompt\n\t\tthis.sendRequest({\n\t\t\tremoveDiff: options.withDiff,\n\t\t\taddBackCode: options.withCode === false\n\t\t})\n\t\tif (options.withDiff) {\n\t\t\tthis.scriptEditorShowDiffMode?.()\n\t\t}\n\t}\n\n\tretryRequest = (messageIndex: number) => {\n\t\tconst message = this.displayMessages[messageIndex]\n\t\tif (message && message.role === 'user') {\n\t\t\tthis.restartGeneration(messageIndex)\n\t\t\tmessage.error = false\n\t\t} else {\n\t\t\tthrow new Error('No user message found at the specified index')\n\t\t}\n\t}\n\n\tprivate getLastUserMessage = () => {\n\t\tfor (let i = this.displayMessages.length - 1; i >= 0; i--) {\n\t\t\tconst message = this.displayMessages[i]\n\t\t\tif (message.role === 'user') {\n\t\t\t\treturn message\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate flagLastMessageAsError = () => {\n\t\tconst lastUserMessage = this.getLastUserMessage()\n\t\tif (lastUserMessage) {\n\t\t\tlastUserMessage.error = true\n\t\t}\n\t}","sourceCodeStart":2386,"sourceCodeEnd":2422,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/AIChatManager.svelte.ts#L2386-L2422","documentation":"Thrown by retryRequest in AIChatManager when the entry at messageIndex in displayMessages is missing or its role is not 'user'. The retry path re-sends a user prompt for regeneration; an index pointing at an assistant message or past the end of the list gives nothing to restart, so this is a caller-input guard.","triggerScenarios":"Thrown at frontend/src/lib/components/copilot/chat/AIChatManager.svelte.ts:2404 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass the index of an actual user message from displayMessages","Re-read the message list before retrying — the conversation may have shifted so the cached index is stale","Disable retry affordances on non-user messages so the call is never made with a bad index"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}