windmill-labs/windmill · error · Error

errorText || 'Failed to authorize debug session'

Error message

errorText || 'Failed to authorize debug session'

What it means

Generic failure branch of signDebugRequest: any non-OK response from /debug/sign whose body does not contain 'not initialized' is thrown verbatim, or as 'Failed to authorize debug session' when the body is empty. This covers auth failures, 404s, 500s, and permission errors.

Source

Thrown at frontend/src/lib/components/debug/MonacoDebugger.svelte:361

		if (!workspace) {
			throw new Error('No workspace selected')
		}

		const response = await fetch(`/api/w/${workspace}/debug/sign`, {
			method: 'POST',
			headers: { 'Content-Type': 'application/json' },
			body: JSON.stringify({ code: codeToSign, language: lang })
		})

		if (!response.ok) {
			const errorText = await response.text()
			// Parse specific error cases for better user messages
			if (errorText.includes('not initialized')) {
				throw new Error(
					'Debug signing is not configured on the server. Please contact your administrator.'
				)
			}
			throw new Error(errorText || 'Failed to authorize debug session')
		}

		return await response.json()
	}

	function getDebugErrorMessage(error: unknown): string {
		const message = error instanceof Error ? error.message : String(error)

		// Handle token verification errors from debugger
		if (message.includes('Token verification failed') || message.includes('Debug token required')) {
			if (message.includes('expired')) {
				return 'Debug session expired. Please try again.'
			}
			if (message.includes('Invalid JWT signature')) {
				return 'Debug authorization failed. The signing key may be misconfigured.'
			}
			if (message.includes('Code hash mismatch')) {
				return 'Code was modified after signing. Please try again.'

View on GitHub (pinned to e474e8803c)

Solutions

  1. Inspect the thrown errorText for the actual HTTP status/message
  2. Re-authenticate / refresh the token, and confirm the user has debug permissions on the workspace
  3. Check that the server deployment actually exposes /api/w/{workspace}/debug/sign

Example fix

// before
if (!response.ok) { /* ... */ throw new Error(errorText || 'Failed to authorize debug session') }
// after
if (!response.ok) {
  if (response.status === 401) throw new Error('Session expired, please log in again')
  throw new Error(errorText || `Failed to authorize debug session (HTTP ${response.status})`)
}
Defensive patterns

Strategy: retry

Validate before calling

if (!(await sessionStillValid())) { await refreshSession() }

Try / catch

try { return await signDebugRequest(src, lang) } catch (e) {
  if (e.message.includes('401') || /expired/i.test(e.message)) { await reauth(); return signDebugRequest(src, lang) }
  sendUserToast(e.message || 'Failed to authorize debug session', true)
}

Prevention

When it happens

Trigger: The sign endpoint returns 401/403 (bad or expired token, insufficient permissions), 404 (endpoint unavailable on this deployment), or 5xx with an error body that does not mention 'not initialized'.

Common situations: Token expired before signing; user lacks debug permissions on the workspace; proxy strips the response body leaving the empty-body fallback; older server without the debug routes.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


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