Budibase/budibase · error · HTTPError

Project package doc '${id}' does not match resource type '${

Error message

Project package doc '${id}' does not match resource type '${importedDoc.resourceType}'.

What it means

validateDocMatchesPath also checks that the doc `_id`'s prefix is valid for its declared resourceType, using RESOURCE_ID_PREFIXES (e.g. PROJECT ids use the `app_`-prefixed PROJECT doc prefix, SCREEN ids the screen prefix). A doc whose id prefix doesn't match its folder/resource type is rejected with this HTTPError (400).

Source

Thrown at packages/server/src/sdk/workspace/projects/backups/imports.ts:351

  [ResourceType.AUTOMATION]: [prefixed(DocumentType.AUTOMATION)],
  [ResourceType.WORKSPACE_APP]: [prefixed(DocumentType.WORKSPACE_APP)],
  [ResourceType.SCREEN]: [prefixed(DocumentType.SCREEN)],
}

const validateDocMatchesPath = (importedDoc: ImportedDoc) => {
  const id = importedDoc.doc._id
  if (!id) {
    throw new HTTPError("Project package contains a doc without an id.", 400)
  }

  const expectedFileName = `${id}.json`
  if (basename(importedDoc.path) !== expectedFileName) {
    throw new HTTPError(`Project package doc path does not match '${id}'.`, 400)
  }

  const validPrefixes = RESOURCE_ID_PREFIXES[importedDoc.resourceType]
  if (!validPrefixes.some(prefix => id.startsWith(prefix))) {
    throw new HTTPError(
      `Project package doc '${id}' does not match resource type '${importedDoc.resourceType}'.`,
      400
    )
  }
}

const remapObjectKeys = <T>(
  value: Record<string, T>,
  idMap: Map<string, string>
) => {
  return Object.fromEntries(
    Object.entries(value).map(([key, nestedValue]) => [
      idMap.get(key) || key,
      nestedValue,
    ])
  )
}

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Move the doc into the folder matching its id prefix (per RESOURCE_ID_PREFIXES in imports.ts), or correct the id/prefix.
  2. Generate ids with the proper helper (e.g. Budibase's `generateID`/prefix utilities) instead of inventing ids by hand.
  3. Re-export from a compatible Budibase version so prefixes and folders align.
  4. Add a validation step: for each doc, assert id startsWith one of RESOURCE_ID_PREFIXES[resourceType] before packaging.

Example fix

// before: documents/screens/screen_xy.json contains _id "ta_abc123"
// after: move it to the tables folder (or fix the id)
mv documents/screens/screen_xy.json documents/tables/ta_abc123.json
Defensive patterns

Strategy: validation

Validate before calling

// mirror RESOURCE_ID_PREFIXES from imports.ts
const PREFIXES: Record<string, string[]> = {
  app: ["app_doc"], // adjust to actual prefixes per resource type
  table: ["ta_doc"],
}

function idMatchesResourceType(id: string, resourceType: string, prefixes: Record<string, string[]>): boolean {
  return (prefixes[resourceType] ?? []).some(p => id.startsWith(p))
}

Try / catch

try {
  await api.importProjectPackage(file)
} catch (err) {
  if (err?.status === 400 && err.message.includes("does not match resource type")) {
    // move the doc to the folder matching its id prefix, or fix the id prefix
  } else throw err
}

Prevention

When it happens

Trigger: A doc under `documents/tables/` whose `_id` doesn't start with the table doc prefix (e.g. a screen id in the tables folder, or an id missing its type prefix entirely), or a resourceType folder that was renamed/moved causing ids to no longer align.

Common situations: Manually moving doc files between resource folders; hand-crafting ids without the correct `ta_`/`vi_`/`ta_doc`-style prefixes; package assembled from multiple exports with mixed id schemes; version changes in id prefix formats.

Related errors


AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/4c0a9cd98b22ee46. Report an issue: GitHub.