windmill-labs/windmill · error

An unexpected error occurred. Please try again.

Error message

An unexpected error occurred. Please try again.

What it means

Catch-all of sendInlineRequest: after logging the original error ('Unexpected error in sendInlineRequest'), any failure that is not an abort (aborted requests return silently) is rethrown as this generic user-facing error, hiding the original cause from the caller.

Source

Thrown at frontend/src/lib/components/copilot/chat/AIChatManager.svelte.ts:2860

			// Fallback: try to take everything after the last <new_code> tag
			const lastNewCodeMatch = reply.match(/<new_code>([\s\S]*)/i)
			if (lastNewCodeMatch && lastNewCodeMatch[1]) {
				const code = lastNewCodeMatch[1].trim().replace(/```/g, '')
				if (!code) {
					throw new Error('AI response contained empty code block')
				}
				return code
			}

			// If no code tags found, throw error with helpful message
			throw new Error('AI response did not contain valid code. Please try rephrasing your request.')
		} catch (error) {
			// if abort controller is aborted, don't throw an error
			if (this.inlineAbortController?.signal.aborted) {
				return
			}
			console.error('Unexpected error in sendInlineRequest:', error)
			throw new Error('An unexpected error occurred. Please try again.')
		}
	}

	// Optional pre-flight hook called once per send, after the user's message
	// bubble + loading indicator are shown optimistically but before the request
	// goes out. Sessions use this to commit/materialise the workspace (creating a
	// staged fork via the API) so the first message targets the correct workspace.
	beforeSend?: () => Promise<void> | void
	afterFirstTurnSaved?: () => Promise<void> | void

	/** A send is between the composer clearing and its turn being installed.
	 * `loading` only rises after the attachment-upkeep awaits, so consumers that
	 * must not read half-installed history (ArrowUp recall) need this instead.
	 * Counted, not boolean: a send recursively flushes queued messages, and the
	 * inner one finishing doesn't mean the outer is done. */
	#sendsInFlight = $state(0)
	get sendInFlight(): boolean {
		return this.#sendsInFlight > 0

View on GitHub (pinned to e474e8803c)

Solutions

  1. Open the browser devtools console and read the 'Unexpected error in sendInlineRequest:' entry to see the underlying error.
  2. Retry the request once — transient network/provider errors are the most common cause.
  3. Verify the AI provider configuration (API key, model, base URL) in instance/workspace settings.
  4. Check the backend logs for the failing AI request for the authoritative error.

Example fix

// before
try { await manager.sendInlineRequest(a, b, c) } catch (e) { /* message is generic */ }
// after
try {
  await manager.sendInlineRequest(a, b, c)
} catch (e) {
  console.error(e) // original cause already logged by the manager
  toast.error('Inline AI edit failed — see console for details')
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await manager.sendInlineRequest(a, b, c)
} catch (e) {
  // original cause was logged by the manager as 'Unexpected error in sendInlineRequest'
  showUserToast('Inline AI edit failed — please try again')
}

Prevention

When it happens

Trigger: Any of: empty reply (290), empty code block (291/292), missing code tag (293), or a network/HTTP failure inside chatRequest — all funnel here and surface as this message.

Common situations: Provider auth failure (401/403), rate limits (429), malformed request, model unavailable, or the extraction errors above; the real cause is only visible in the browser console log.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/4d33d74a611c70d4. Report an issue: GitHub.