{"record":{"id":"65dc27679d73590b","repo":"hcengineering/platform","slug":"workspacenotfound-65dc27","errorCode":"WorkspaceNotFound","errorMessage":"WorkspaceNotFound","messagePattern":"WorkspaceNotFound","errorType":"error_code","errorClass":"PlatformError","httpStatus":404,"severity":"error","filePath":"server/account/src/utils.ts","lineNumber":806,"sourceCode":"    if (workspace == null) {\n      workspace = await getWorkspaceById(db, decodedToken.workspace)\n    }\n    extra = decodedToken.extra\n    grant = decodedToken.grant\n    sub = decodedToken.sub\n    exp = decodedToken.exp\n    nbf = decodedToken.nbf\n  } catch (e) {\n    if (workspace?.allowReadOnlyGuest === true) {\n      accountUuid = readOnlyGuestAccountUuid\n    } else {\n      throw e\n    }\n  }\n\n  if (workspace == null) {\n    ctx.error('Workspace not found in selectWorkspace', { workspaceUrl, kind, accountUuid, extra })\n    throw new PlatformError(new Status(Severity.ERROR, platform.status.WorkspaceNotFound, { workspaceUrl }))\n  }\n\n  const getKind = (region: string | undefined): EndpointKind => {\n    switch (kind) {\n      case 'external':\n        return EndpointKind.External\n      case 'internal':\n        return EndpointKind.Internal\n      case 'byregion':\n        return externalRegions.includes(region ?? '') ? EndpointKind.External : EndpointKind.Internal\n      default:\n        return meta?.clientNetworkPosition === 'internal' ? EndpointKind.Internal : EndpointKind.External\n    }\n  }\n\n  if (isGuest(accountUuid, extra)) {\n    const workspace = await getWorkspaceByUrl(db, workspaceUrl)\n    if (workspace == null) {","sourceCodeStart":788,"sourceCodeEnd":824,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/server/account/src/utils.ts#L788-L824","documentation":"WorkspaceNotFound is thrown by selectWorkspace when no workspace matching the given workspaceUrl could be resolved. The lookup result is null, so the service cannot compute an endpoint for the user and aborts with the workspaceUrl in the status.","triggerScenarios":"selectWorkspace (server/account/src/utils.ts:806) invoked with a workspaceUrl that does not match any workspace record in the DB.","commonSituations":"Client configured with an old/renamed workspace URL; DNS or reverse-proxy pointing to a workspace that was deleted; typos in the URL passed via config or cookie.","solutions":["Verify the workspaceUrl exists via getWorkspaceByUrl before calling selectWorkspace","Update client configuration to the current workspace URL after a rename/move","Recreate the workspace if it was deleted, or point the user to an existing one"],"exampleFix":"// before\nconst result = await selectWorkspace(ctx, db, workspaceUrl, kind, accountUuid, extra)\n// after\nconst ws = await getWorkspaceByUrl(ctx, db, workspaceUrl)\nif (ws == null) throw new Error(`Unknown workspace URL: ${workspaceUrl}`)\nconst result = await selectWorkspace(ctx, db, workspaceUrl, kind, accountUuid, extra)","handlingStrategy":"validation","validationCode":"const ws = await getWorkspaceByUrl(ctx, db, workspaceUrl)\nif (ws == null) throw new Error(`Unknown workspace URL: ${workspaceUrl}`)","typeGuard":"function isWorkspace(w: unknown): w is { uuid: WorkspaceUuid, region: string } { return w != null && typeof (w as any).uuid === 'string' && typeof (w as any).region === 'string' }","tryCatchPattern":"try { return await selectWorkspace(ctx, db, workspaceUrl, kind, accountUuid, extra) } catch (err) { if (isStatus(err, platform.status.WorkspaceNotFound)) { redirectToWorkspacePicker(); return; } throw err }","preventionTips":["Validate workspace URLs in client config at startup","Handle workspace renames by updating stored URLs/links","Present a workspace picker instead of hardcoding a single URL"],"tags":["workspace","not-found","url"],"backgroundTag":"resource-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}