Budibase/budibase · error · Error
Could not determine workspace for Project import
Error message
Could not determine workspace for Project import
What it means
importProject requires a workspace (app) context because the imported Project must be created inside a target workspace. The request context has no workspace id, so the function fails fast with a plain Error (not an HTTPError).
Source
Thrown at packages/server/src/sdk/workspace/projects/backups/imports.ts:1084
name: doc.name || "Unknown",
reason:
"Agent integration secrets are excluded from Project exports and must be reconfigured after import.",
},
]
}
}
return []
})
}
export async function importProject(
file: { path: string },
opts?: { encryptPassword?: string }
): Promise<ImportProjectResponse> {
const workspaceId = context.getWorkspaceId()
if (!workspaceId) {
throw new Error("Could not determine workspace for Project import")
}
const extracted = await extractProjectPackage(file, opts?.encryptPassword)
const insertedDocs: InsertedDocRef[] = []
let importedProject: Project | undefined
try {
importedProject = await sdk.projects.create({
name: extracted.project.name,
description: extracted.project.description,
color: extracted.project.color,
})
const importedProjectId = importedProject._id!
const idMap = new Map<string, string>([
[extracted.project._id!, importedProjectId],
[extracted.manifest.sourceWorkspace.id, workspaceId],
])
View on GitHub (pinned to a81a902e9a)
Solutions
- Ensure the import is invoked within a request that includes the workspace/app id (e.g. appId header or :appId path segment)
- Wrap SDK calls in scripts with context.getWorkspaceContext / doInWorkspaceContext passing a valid workspace id
- Verify the HTTP client (curl, automation, proxy) actually sends the app identifier on the import route
- Log context.getWorkspaceId() at the call site to confirm it is set before calling importProject
Example fix
// before
await importProject({ path: filePath })
// after
await context.doInWorkspaceContext(workspaceId, () =>
importProject({ path: filePath })
) Defensive patterns
Strategy: type-guard
Validate before calling
if (!context.getWorkspaceId()) {
throw new Error("importProject requires a workspace context")
}
await importProject({ path }) Type guard
const hasWorkspaceContext = (): boolean => typeof context.getWorkspaceId() === "string" && context.getWorkspaceId()!.length > 0
Try / catch
try {
await importProject({ path })
} catch (e) {
if (String(e.message).includes("Could not determine workspace")) {
// re-run inside doInWorkspaceContext with an explicit workspace id
}
} Prevention
- Always call importProject inside a workspace-scoped request or doInWorkspaceContext
- Propagate the appId through background jobs and workers
- Assert workspace context at the start of import scripts
When it happens
Trigger: Calling importProject outside of a workspace-scoped request context: background scripts hitting the SDK directly, cron jobs, or API routes that did not resolve/set the workspace (missing appId header, wrong URL path, context not opened).
Common situations: Custom endpoints or scripts importing packages without wrapping the call in context with a workspace id; calling from the worker in a job that did not carry the appId through; proxy mis-routing so the app id is not extracted.
Related errors
- workspaceId is required
- Workspace context is required
- workspaceId is required
- Unable to determine delimiter
- User ID missing
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/0ad45705edadda6e.
Report an issue: GitHub.