windmill-labs/windmill · error
No user message found at the specified index
Error message
No user message found at the specified index
What it means
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.
Source
Thrown at frontend/src/lib/components/copilot/chat/AIChatManager.svelte.ts:2404
this.contextManager.setAskAiContext(options)
}
this.instructions = prompt
this.sendRequest({
removeDiff: options.withDiff,
addBackCode: options.withCode === false
})
if (options.withDiff) {
this.scriptEditorShowDiffMode?.()
}
}
retryRequest = (messageIndex: number) => {
const message = this.displayMessages[messageIndex]
if (message && message.role === 'user') {
this.restartGeneration(messageIndex)
message.error = false
} else {
throw new Error('No user message found at the specified index')
}
}
private getLastUserMessage = () => {
for (let i = this.displayMessages.length - 1; i >= 0; i--) {
const message = this.displayMessages[i]
if (message.role === 'user') {
return message
}
}
}
private flagLastMessageAsError = () => {
const lastUserMessage = this.getLastUserMessage()
if (lastUserMessage) {
lastUserMessage.error = true
}
}View on GitHub (pinned to e474e8803c)
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
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at frontend/src/lib/components/copilot/chat/AIChatManager.svelte.ts:2404 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/0c981746af947e52.
Report an issue: GitHub.