Budibase/budibase · error · HTTPError

Project app with id '${workspaceApp._id}' not found.

Error message

Project app with id '${workspaceApp._id}' not found.

What it means

update() fetches the persisted workspace app by _id before writing; if get() returns undefined the id does not exist in the workspace DB and a 404 HTTPError is thrown. This protects against updating non-existent or foreign-doc ids.

Source

Thrown at packages/server/src/sdk/workspace/workspaceApps/crud.ts:138

  return response.doc
}

export async function duplicate(
  appToDuplicate: WorkspaceApp
): Promise<WorkspaceApp> {
  const duplicated = await createDuplicatedApp(appToDuplicate)
  await duplicateScreens(appToDuplicate._id as string, duplicated._id as string)
  return duplicated
}

export async function update(
  workspaceApp: WorkspaceAppUpdate
): Promise<WorkspaceApp> {
  const db = context.getWorkspaceDB()

  const persisted = await get(workspaceApp._id!)
  if (!persisted) {
    throw new HTTPError(
      `Project app with id '${workspaceApp._id}' not found.`,
      404
    )
  }
  if (workspaceApp.name !== persisted.name) {
    await guardName(workspaceApp.name, workspaceApp._id)
  }
  const docToUpdate: RequiredKeys<WorkspaceApp> = {
    _id: workspaceApp._id,
    _rev: workspaceApp._rev,
    name: workspaceApp.name,
    url: workspaceApp.url,
    navigation: workspaceApp.navigation,
    theme: hasOwn(workspaceApp, "theme") ? workspaceApp.theme : persisted.theme,
    customTheme: hasOwn(workspaceApp, "customTheme")
      ? workspaceApp.customTheme
      : persisted.customTheme,
    disabled: workspaceApp.disabled,

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Verify the _id exists via sdk.workspaceApps.fetch()/get() before updating
  2. Ensure the correct workspace/app context is active so context.getWorkspaceDB() points at the right DB
  3. Fetch fresh docs to also get a current _rev before updating

Example fix

// before
await sdk.workspaceApps.update({ _id: someId, name: 'New', url: '/new' })
// after
const persisted = await sdk.workspaceApps.get(someId)
if (!persisted) throw new Error(`Workspace app ${someId} not found`)
await sdk.workspaceApps.update({ ...persisted, name: 'New' })
Defensive patterns

Strategy: validation

Validate before calling

const persisted = await sdk.workspaceApps.get(id)
if (!persisted) throw new Error(`Workspace app ${id} not found in this workspace`)

Type guard

function workspaceAppExists(app) {
  return app !== undefined && typeof app === 'object' && !!app._id && !!app._rev
}

Try / catch

try {
  await sdk.workspaceApps.update(update)
} catch (e) {
  if (e?.status === 404) {
    // refresh the app list; the id is stale or from another workspace
  } else throw e
}

Prevention

When it happens

Trigger: Calling sdk.workspaceApps.update with a WorkspaceAppUpdate whose _id does not exist in the current workspace DB — e.g. a stale/hardcoded id, an id from another app/workspace, or an app already deleted.

Common situations: Frontend holding an outdated list after the app was deleted elsewhere; ids copied across environments (dev vs prod workspace dbs differ); wrong workspace context set so the doc isn't in the active DB.

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 Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/e123c478a15b2917. Report an issue: GitHub.