{"record":{"id":"e0fa4027a399875d","repo":"windmill-labs/windmill","slug":"no-workspace-available","errorCode":null,"errorMessage":"No workspace available","messagePattern":"No workspace available","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/ata/apis.ts","lineNumber":11,"sourceCode":"//  https://github.com/jsdelivr/data.jsdelivr.com\n\nimport pLimit from 'p-limit'\nimport { workspaceStore } from '$lib/stores'\nimport { get } from 'svelte/store'\n\n// Backend proxy fallback functions\nconst getBackendProxyUrl = () => {\n\tconst workspace = get(workspaceStore)\n\tif (!workspace) {\n\t\tthrow new Error('No workspace available')\n\t}\n\treturn `/api/w/${workspace}/npm_proxy`\n}\n\nconst backendProxyApi = async <T>(endpoint: string, resLimit: ResLimit): Promise<T | Error> => {\n\tif (isOverlimit(resLimit)) {\n\t\tconsole.warn(\n\t\t\t`Exceeded limit of types downloaded for the needs of the assistant fetching: ${endpoint}, ${resLimit.usage}`\n\t\t)\n\t\treturn new Error('Exceeded limit of 100MB of data downloaded.')\n\t}\n\n\ttry {\n\t\tconst baseUrl = getBackendProxyUrl()\n\t\tconst url = `${baseUrl}${endpoint}`\n\n\t\t// `await`, not a bare `return`: an async function adopts a returned promise after\n\t\t// leaving the try block, so a rejection would escape the catch below.","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/ata/apis.ts#L1-L29","documentation":"getBackendProxyUrl() in the ATA (npm proxy) module builds the /api/w/<workspace>/npm_proxy URL from the current workspaceStore value. If no workspace is selected (store is empty/null), it throws 'No workspace available'. This is a guard ensuring npm-proxy requests are always workspace-scoped.","triggerScenarios":"Calling backendProxyApi-backed functions (baseUrl, res, proxyUrl paths) while workspaceStore is undefined/null — typically on a page outside a workspace context or before the workspace store is initialized from the URL.","commonSituations":"Rendering a component that auto-fetches ATA data before the router sets the workspace; using the component in an app preview/test context where no workspace is in scope; a stale or corrupted URL missing the workspace segment.","solutions":["Ensure the calling page/component runs inside a workspace route so workspaceStore is populated before any npm-proxy request.","Guard the request: check get(workspaceStore) first and skip or defer the call when empty.","Fix the URL — if you navigated directly to a page without the /w/<workspace>/ prefix, navigate via the workspace-scoped route.","If initialization is a race, wait for the workspace store to be set (await its load promise / subscribe until defined) before firing requests."],"exampleFix":"// before\nconst data = await backendProxyApi(endpoint, resLimit)\n// after\nconst workspace = get(workspaceStore)\nif (!workspace) return // or queue until workspace is set\nconst data = await backendProxyApi(endpoint, resLimit)","handlingStrategy":"type-guard","validationCode":"const workspace = get(workspaceStore)\nif (!workspace) {\n  // defer or skip npm-proxy request until a workspace is active\n}","typeGuard":"function hasActiveWorkspace(): boolean {\n  return get(workspaceStore) != null\n}","tryCatchPattern":"try {\n  const data = await backendProxyApi(endpoint, resLimit)\n} catch (e) {\n  if (e instanceof Error && e.message === 'No workspace available') {\n    // re-run once workspaceStore is populated\n  } else throw e\n}","preventionTips":["Mount npm-proxy-dependent components only inside workspace-scoped routes.","Subscribe to workspaceStore and trigger fetches in an effect once a workspace exists.","Check the URL contains /w/<workspace>/ before direct navigation."],"tags":["frontend","workspace","svelte-store","routing"],"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-08T10:18:20.063Z"}