{"record":{"id":"ad6835ce05af23dd","repo":"windmill-labs/windmill","slug":"errortext-failed-to-authorize-debug-session","errorCode":null,"errorMessage":"errorText || 'Failed to authorize debug session'","messagePattern":"errorText \\|\\| 'Failed to authorize debug session'","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/debug/MonacoDebugger.svelte","lineNumber":361,"sourceCode":"\t\tif (!workspace) {\n\t\t\tthrow new Error('No workspace selected')\n\t\t}\n\n\t\tconst response = await fetch(`/api/w/${workspace}/debug/sign`, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: { 'Content-Type': 'application/json' },\n\t\t\tbody: JSON.stringify({ code: codeToSign, language: lang })\n\t\t})\n\n\t\tif (!response.ok) {\n\t\t\tconst errorText = await response.text()\n\t\t\t// Parse specific error cases for better user messages\n\t\t\tif (errorText.includes('not initialized')) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Debug signing is not configured on the server. Please contact your administrator.'\n\t\t\t\t)\n\t\t\t}\n\t\t\tthrow new Error(errorText || 'Failed to authorize debug session')\n\t\t}\n\n\t\treturn await response.json()\n\t}\n\n\tfunction getDebugErrorMessage(error: unknown): string {\n\t\tconst message = error instanceof Error ? error.message : String(error)\n\n\t\t// Handle token verification errors from debugger\n\t\tif (message.includes('Token verification failed') || message.includes('Debug token required')) {\n\t\t\tif (message.includes('expired')) {\n\t\t\t\treturn 'Debug session expired. Please try again.'\n\t\t\t}\n\t\t\tif (message.includes('Invalid JWT signature')) {\n\t\t\t\treturn 'Debug authorization failed. The signing key may be misconfigured.'\n\t\t\t}\n\t\t\tif (message.includes('Code hash mismatch')) {\n\t\t\t\treturn 'Code was modified after signing. Please try again.'","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/debug/MonacoDebugger.svelte#L343-L379","documentation":"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.","triggerScenarios":"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'.","commonSituations":"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.","solutions":["Inspect the thrown errorText for the actual HTTP status/message","Re-authenticate / refresh the token, and confirm the user has debug permissions on the workspace","Check that the server deployment actually exposes /api/w/{workspace}/debug/sign"],"exampleFix":"// before\nif (!response.ok) { /* ... */ throw new Error(errorText || 'Failed to authorize debug session') }\n// after\nif (!response.ok) {\n  if (response.status === 401) throw new Error('Session expired, please log in again')\n  throw new Error(errorText || `Failed to authorize debug session (HTTP ${response.status})`)\n}","handlingStrategy":"retry","validationCode":"if (!(await sessionStillValid())) { await refreshSession() }","typeGuard":null,"tryCatchPattern":"try { return await signDebugRequest(src, lang) } catch (e) {\n  if (e.message.includes('401') || /expired/i.test(e.message)) { await reauth(); return signDebugRequest(src, lang) }\n  sendUserToast(e.message || 'Failed to authorize debug session', true)\n}","preventionTips":["Refresh the session token before long debug sessions","Include the HTTP status in client-thrown errors","Confirm the deployment serves /debug/sign before enabling the UI"],"tags":["http-error","debugging","auth"],"backgroundTag":"http-request-failed","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"}