hcengineering/platform · error · PlatformError

WorkspaceNotFound

WorkspaceNotFound

Error message

WorkspaceNotFound

What it means

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.

Source

Thrown at server/account/src/utils.ts:806

    if (workspace == null) {
      workspace = await getWorkspaceById(db, decodedToken.workspace)
    }
    extra = decodedToken.extra
    grant = decodedToken.grant
    sub = decodedToken.sub
    exp = decodedToken.exp
    nbf = decodedToken.nbf
  } catch (e) {
    if (workspace?.allowReadOnlyGuest === true) {
      accountUuid = readOnlyGuestAccountUuid
    } else {
      throw e
    }
  }

  if (workspace == null) {
    ctx.error('Workspace not found in selectWorkspace', { workspaceUrl, kind, accountUuid, extra })
    throw new PlatformError(new Status(Severity.ERROR, platform.status.WorkspaceNotFound, { workspaceUrl }))
  }

  const getKind = (region: string | undefined): EndpointKind => {
    switch (kind) {
      case 'external':
        return EndpointKind.External
      case 'internal':
        return EndpointKind.Internal
      case 'byregion':
        return externalRegions.includes(region ?? '') ? EndpointKind.External : EndpointKind.Internal
      default:
        return meta?.clientNetworkPosition === 'internal' ? EndpointKind.Internal : EndpointKind.External
    }
  }

  if (isGuest(accountUuid, extra)) {
    const workspace = await getWorkspaceByUrl(db, workspaceUrl)
    if (workspace == null) {

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Verify the workspaceUrl exists via getWorkspaceByUrl before calling selectWorkspace
  2. Update client configuration to the current workspace URL after a rename/move
  3. Recreate the workspace if it was deleted, or point the user to an existing one

Example fix

// before
const result = await selectWorkspace(ctx, db, workspaceUrl, kind, accountUuid, extra)
// after
const ws = await getWorkspaceByUrl(ctx, db, workspaceUrl)
if (ws == null) throw new Error(`Unknown workspace URL: ${workspaceUrl}`)
const result = await selectWorkspace(ctx, db, workspaceUrl, kind, accountUuid, extra)
Defensive patterns

Strategy: validation

Validate before calling

const ws = await getWorkspaceByUrl(ctx, db, workspaceUrl)
if (ws == null) throw new Error(`Unknown workspace URL: ${workspaceUrl}`)

Type guard

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' }

Try / catch

try { return await selectWorkspace(ctx, db, workspaceUrl, kind, accountUuid, extra) } catch (err) { if (isStatus(err, platform.status.WorkspaceNotFound)) { redirectToWorkspacePicker(); return; } throw err }

Prevention

When it happens

Trigger: selectWorkspace (server/account/src/utils.ts:806) invoked with a workspaceUrl that does not match any workspace record in the DB.

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/65dc27679d73590b. Report an issue: GitHub.