{"record":{"id":"e8253abc698a6e97","repo":"mastra-ai/mastra","slug":"workspace-with-id-id-not-found","errorCode":null,"errorMessage":"Workspace with id ${id} not found","messagePattern":"Workspace with id (.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/storage/domains/workspaces/inmemory.ts","lineNumber":88,"sourceCode":"    await this.createVersion({\n      id: versionId,\n      workspaceId: workspace.id,\n      versionNumber: 1,\n      ...snapshotConfig,\n      changedFields: Object.keys(snapshotConfig),\n      changeMessage: 'Initial version',\n    });\n\n    // Return the thin record\n    return this.deepCopyConfig(newConfig);\n  }\n\n  async update(input: StorageUpdateWorkspaceInput): Promise<StorageWorkspaceType> {\n    const { id, ...updates } = input;\n\n    const existingConfig = this.db.workspaces.get(id);\n    if (!existingConfig) {\n      throw new Error(`Workspace with id ${id} not found`);\n    }\n\n    // Separate metadata fields from config fields\n    const { authorId, activeVersionId, metadata, status, ...rawConfigFields } = updates;\n\n    // Strip undefined keys so omitted PATCH fields don't overwrite persisted values\n    const configFields: Record<string, unknown> = {};\n    for (const [key, value] of Object.entries(rawConfigFields)) {\n      if (value !== undefined) configFields[key] = value;\n    }\n\n    // Config field names from StorageWorkspaceSnapshotType\n    const configFieldNames = [\n      'name',\n      'description',\n      'filesystem',\n      'sandbox',\n      'mounts',","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/storage/domains/workspaces/inmemory.ts#L70-L106","documentation":"Thrown by MastraStorage's in-memory workspace domain when update() is called with an id that has no persisted workspace config. The store does a Map lookup on db.workspaces and fails fast rather than silently returning an unmodified record. It is a 'patch a nonexistent resource' error, analogous to a 404 on an HTTP PATCH.","triggerScenarios":"Calling storage.workspaces.update({ id: 'nonexistent-id', name: 'x' }) (or any other field) when no workspace with that id was created in this storage instance; using an id from a different storage backend; referencing a workspace dropped by clear()/reset; using a stale id after process restart since the in-memory store is volatile.","commonSituations":"Hardcoded test ids that were never created; passing a workflow or agent id instead of a workspace id; two storage instances (e.g. unit test fixtures) each with their own in-memory Map; script creating the workspace in one process and updating it in another.","solutions":["Verify the id exists by calling getWorkspaceById(id) or list() before updating, and create it if missing","Confirm you are using the same storage instance that holds the workspace (not a fresh InMemoryDomain instance)","Check the id value for typos or copying the wrong entity's id (agent vs workspace)","Persist durable workspaces in a real storage backend (LibSQL/Postgres/etc.) instead of in-memory if ids must survive restarts"],"exampleFix":"// before\nawait storage.workspaces.update({ id: workspaceId, name: 'Renamed' }); // throws if missing\n// after\nconst existing = await storage.workspaces.getWorkspaceById(workspaceId);\nif (!existing) {\n  throw new Error(`Workspace ${workspaceId} does not exist; create it first`);\n}\nawait storage.workspaces.update({ id: workspaceId, name: 'Renamed' });","handlingStrategy":"validation","validationCode":"const existing = await storage.workspaces.getWorkspaceById(id);\nif (!existing) throw new Error(`Workspace ${id} not found; create it before updating`);","typeGuard":null,"tryCatchPattern":"try {\n  await storage.workspaces.update({ id, ...updates });\n} catch (err) {\n  if (err instanceof Error && err.message === `Workspace with id ${id} not found`) {\n    // create the workspace or surface a 404-style response\n  } else throw err;\n}","preventionTips":["Always getWorkspaceById before update in PATCH-style flows","Use one shared storage instance per process/test; avoid ad-hoc in-memory instances","Never hardcode workspace ids in fixtures; capture ids from create()","Prefer persistent storage backends for anything spanning process restarts"],"tags":["storage","workspace","not-found","in-memory"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}