{"record":{"id":"97a30099547e6809","repo":"windmill-labs/windmill","slug":"no-workspace-selected","errorCode":null,"errorMessage":"No workspace selected","messagePattern":"No workspace selected","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/debug/debugUtils.ts","lineNumber":56,"sourceCode":"\n\t\treturn envVars\n\t} catch (error) {\n\t\tconsole.error('Failed to fetch contextual variables:', error)\n\t\treturn {}\n\t}\n}\n\n/**\n * Sign a debug request with the backend. This creates an audit log entry\n * and returns a signed token that authorizes the debug session.\n */\nexport async function signDebugRequest(\n\tworkspace: string,\n\tcode: string,\n\tlanguage: string\n): Promise<{ token: string; code: string; job_id: string }> {\n\tif (!workspace) {\n\t\tthrow new Error('No workspace selected')\n\t}\n\n\tconst response = await fetch(`/api/w/${workspace}/debug/sign`, {\n\t\tmethod: 'POST',\n\t\theaders: { 'Content-Type': 'application/json' },\n\t\tbody: JSON.stringify({ code, language })\n\t})\n\n\tif (!response.ok) {\n\t\tconst errorText = await response.text()\n\t\tif (errorText.includes('not initialized')) {\n\t\t\tthrow new Error(\n\t\t\t\t'Debug signing is not configured on the server. Please contact your administrator.'\n\t\t\t)\n\t\t}\n\t\tthrow new Error(errorText || 'Failed to authorize debug session')\n\t}\n","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/debug/debugUtils.ts#L38-L74","documentation":"signDebugRequest signs a debug session with the backend by POSTing to /api/w/{workspace}/debug/sign, which creates an audit log entry and returns a signed token. The function requires a non-empty workspace id to build the API path. It throws 'No workspace selected' synchronously when workspace is falsy ('' or undefined), because a debug request cannot be scoped without a workspace.","triggerScenarios":"Calling signDebugRequest with an empty-string, null, or undefined workspace argument. In the app this happens when the script/flow editor loads before the workspace is resolved from the URL/store (e.g. direct deep link, workspace store not yet initialized) and the debugger tries to sign its request.","commonSituations":"Opening an editor page before workspace context hydration completes; embedding the editor in a context that has no workspace selected; a regression where the workspace store is cleared on navigation; calling the utility from custom code without passing the workspace.","solutions":["Ensure the workspace is resolved and non-empty before invoking any debug flow (check the workspace store/URL param).","Gate the debug-sign call behind a check like `if (!workspace) return/skip` until workspace context is ready.","Verify the app is not used outside a workspace route (debug signing is workspace-scoped by design)."],"exampleFix":"// before\nconst { token } = await signDebugRequest(workspaceStore.val ?? '', code, language)\n// after\nif (!workspace) return\nconst { token } = await signDebugRequest(workspace, code, language)","handlingStrategy":"validation","validationCode":"if (!workspace) { /* skip sign or surface 'select a workspace' */ return }","typeGuard":null,"tryCatchPattern":"try { const { token } = await signDebugRequest(ws, code, lang) } catch (e) { if ((e as Error).message === 'No workspace selected') promptWorkspaceSelection(); else throw e }","preventionTips":["Derive workspace from the route/store at call time and assert non-empty in dev builds.","Gate debug UI behind a `workspace` derived value so buttons are disabled without it."],"tags":["debugging","workspace","frontend","guard-clause"],"backgroundTag":"missing-workspace-context","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}