{"record":{"id":"1fcb3056192210b8","repo":"different-ai/openwork","slug":"workspace-missing","errorCode":"workspace_missing","errorMessage":"At least one workspace is required for engine runtime config","messagePattern":"At least one workspace is required for engine runtime config","errorType":"http","errorClass":"ApiError","httpStatus":400,"severity":"error","filePath":"apps/server/src/server.ts","lineNumber":318,"sourceCode":"  const provider = body.provider;\n  if (!isRecord(provider)) {\n    throw new ApiError(400, \"invalid_payload\", \"provider must be an object\");\n  }\n  for (const [providerId, value] of Object.entries(provider)) {\n    if (!providerId.trim()) {\n      throw new ApiError(400, \"invalid_payload\", \"provider keys must be non-empty strings\");\n    }\n    if (value !== null && !isRecord(value)) {\n      throw new ApiError(400, \"invalid_payload\", \"provider values must be objects or null\");\n    }\n  }\n  return provider;\n}\n\nfunction resolveEngineRuntimeWorkspace(config: ServerConfig): WorkspaceInfo {\n  const workspace = findManagedEngineWorkspace(config.workspaces) ?? config.workspaces[0];\n  if (!workspace) {\n    throw new ApiError(400, \"workspace_missing\", \"At least one workspace is required for engine runtime config\");\n  }\n  return workspace;\n}\n\nfunction redactBearerTokens(value: string): string {\n  return value.replace(/Bearer\\s+\\S+/g, \"Bearer [redacted]\");\n}\n\nfunction redactManagedRuntimeValue(value: unknown, path: string[], insideMcpHeaders: boolean): unknown {\n  if (typeof value === \"string\") return insideMcpHeaders ? \"[redacted]\" : redactBearerTokens(value);\n  if (Array.isArray(value)) {\n    return value.map((entry, index) => redactManagedRuntimeValue(entry, [...path, String(index)], insideMcpHeaders));\n  }\n  if (!isRecord(value)) return value;\n\n  return Object.fromEntries(\n    Object.entries(value).map(([key, child]) => {\n      const childInsideMcpHeaders = insideMcpHeaders || (path.length === 2 && path[0] === \"mcp\" && key === \"headers\");","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/server/src/server.ts#L300-L336","documentation":"This 400 workspace_missing error is thrown by resolveEngineRuntimeWorkspace when the server config has no workspaces at all — neither a managed engine workspace nor any fallback entry. Engine runtime configuration endpoints (provider sync, workspace config) need at least one workspace to operate against.","triggerScenarios":"Calling cloudProviderSync or the workspace config endpoint on a server whose config.workspaces array is empty — e.g. a freshly provisioned server before any workspace was created, or after all workspaces were deleted.","commonSituations":"Fresh server setup where workspace creation step was skipped; config file wiped or mis-migrated; a script deleted the last workspace then attempted runtime config changes.","solutions":["Create a workspace on the server first, then retry the runtime config call","Re-add the workspace entry to the server config and reload","Check config.workspaces in the server config file for accidental emptying"],"exampleFix":"// before\nawait syncProviders(serverId); // fails: no workspaces\n// after\nawait createWorkspace(serverId, { name: \"default\" });\nawait syncProviders(serverId);","handlingStrategy":"validation","validationCode":"const ws = await listWorkspaces(serverId);\nif (!ws.length) throw new Error(\"create a workspace before configuring engine runtime\");","typeGuard":null,"tryCatchPattern":"try {\n  await syncCloudProviders(serverId);\n} catch (e) {\n  if (e.code === \"workspace_missing\") {\n    await createWorkspace(serverId, { name: \"default\" });\n    await syncCloudProviders(serverId);\n  } else throw e;\n}","preventionTips":["Always provision at least one workspace during server setup","Verify workspaces exist before scripted runtime config changes","Don't delete the last workspace without recreating one"],"tags":["workspace","configuration","http-400"],"backgroundTag":"missing-workspace","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}