{"record":{"id":"95839daa3bc264e1","repo":"Budibase/budibase","slug":"destination-workspace-does-not-exist","errorCode":null,"errorMessage":"Destination workspace does not exist","messagePattern":"Destination workspace does not exist","errorType":"validation","errorClass":"HTTPError","httpStatus":400,"severity":"error","filePath":"packages/server/src/sdk/workspace/resources/index.ts","lineNumber":362,"sourceCode":"      ]\n\n      addDependencies(project._id, directMembers)\n      // e.g. a project-assigned query may depend on a table, which depends on a datasource.\n      for (const member of directMembers) {\n        addDependencies(project._id, collectTransitiveDependencies(member.id))\n      }\n    }\n  }\n\n  return dependencies\n}\n\nasync function getDestinationDb(toWorkspace: string) {\n  const destinationDb = db.getDB(db.getDevWorkspaceID(toWorkspace), {\n    skip_setup: true,\n  })\n  if (!(await destinationDb.exists())) {\n    throw new HTTPError(\"Destination workspace does not exist\", 400)\n  }\n\n  return destinationDb\n}\n\nconst resourceTypeIdPrefixes: Record<ResourceType, string> = {\n  [ResourceType.PROJECT]: prefixed(DocumentType.PROJECT),\n  [ResourceType.AGENT]: prefixed(DocumentType.AGENT),\n  [ResourceType.DATASOURCE]: prefixed(DocumentType.DATASOURCE),\n  [ResourceType.TABLE]: prefixed(DocumentType.TABLE),\n  [ResourceType.ROW_ACTION]: prefixed(DocumentType.ROW_ACTIONS),\n  [ResourceType.QUERY]: prefixed(DocumentType.QUERY),\n  [ResourceType.AUTOMATION]: prefixed(DocumentType.AUTOMATION),\n  [ResourceType.WORKSPACE_APP]: prefixed(DocumentType.WORKSPACE_APP),\n  [ResourceType.SCREEN]: prefixed(DocumentType.SCREEN),\n}\n\nfunction getResourceType(id: string): ResourceType | undefined {","sourceCodeStart":344,"sourceCodeEnd":380,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/resources/index.ts#L344-L380","documentation":"Thrown by getDestinationDb during resource copy/import operations when the target workspace's dev database does not exist (checked with skip_setup so it is never auto-created). The copy operation is refused with a 400 rather than silently creating an empty destination.","triggerScenarios":"Calling a resource copy/import (e.g. duplicating a table or datasource into another workspace) where `toWorkspace` refers to an app id that has never been created or whose dev database was deleted; passing a workspace/app id from a different tenant.","commonSituations":"Copying resources into an app id from an environment export that was never provisioned; typo'd or stale app id in automation/script; the destination app was deleted while a copy job was queued; cross-tenant id reuse.","solutions":["Confirm the destination workspace/app exists (list apps or open it in the builder) before running the copy","Create the destination workspace/app first, then retry the copy","Verify toWorkspace is the app/workspace id of the same tenant, not a name or an id from another environment","Check the destination's dev DB directly in CouchDB to confirm it wasn't deleted"],"exampleFix":"// before\nawait resources.copy(table, { toWorkspace: targetAppId })\n// after\nconst target = await workspaces.get(targetAppId)\nif (!target) throw new Error(`Destination app ${targetAppId} missing`)\nawait resources.copy(table, { toWorkspace: targetAppId })","handlingStrategy":"validation","validationCode":"const dest = await workspaces.get(toWorkspace)\nif (!dest) throw new Error(`Destination workspace ${toWorkspace} not provisioned`)","typeGuard":"function isWorkspaceId(id: string): boolean\n  return typeof id === \"string\" && id.length > 0 && id !== \"undefined\" && id !== \"null\"","tryCatchPattern":"try {\n  await copyResources(payload, toWorkspace)\n} catch (e) {\n  if (e?.status === 400 && /Destination workspace/i.test(e.message)) {\n    throw new Error(`Create workspace ${toWorkspace} before copying`)\n  }\n  throw e\n}","preventionTips":["Resolve destination workspace ids from the app list API, never from environment exports or memory","Provision the destination app before scheduling copy jobs","Validate the id belongs to the current tenant before copying","Watch for deleted-destination races: re-check existence in retry logic"],"tags":["http-400","workspace","copy-resources","couchdb"],"backgroundTag":"destination-database-missing","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}