{"record":{"id":"0e77d5a5199e3af5","repo":"paperclipai/paperclip","slug":"workspace-not-found","errorCode":null,"errorMessage":"Workspace not found","messagePattern":"Workspace not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/plugins/plugin-workspace-diff/src/worker.ts","lineNumber":65,"sourceCode":"    ctx.logger.info(`${PLUGIN_NAME} plugin setup`);\n    const workspaceDiff = workspaceDiffService();\n\n    ctx.data.register(\"workspace-diff\", async (params: Record<string, unknown>) => {\n      const workspaceId = readString(params.workspaceId);\n      const companyId = readString(params.companyId);\n      if (!workspaceId || !companyId) {\n        throw new Error(\"workspaceId and companyId are required\");\n      }\n\n      if (params.entityType === \"project_workspace\") {\n        const projectId = readString(params.projectId);\n        if (!projectId) {\n          throw new Error(\"projectId is required for project workspace diffs\");\n        }\n        const workspaces = await ctx.projects.listWorkspaces(projectId, companyId);\n        const workspace = workspaces.find((candidate) => candidate.id === workspaceId);\n        if (!workspace) {\n          throw new Error(\"Workspace not found\");\n        }\n        return workspaceDiff.getDiff({\n          id: workspace.id,\n          companyId,\n          cwd: workspace.path,\n          baseRef: resolveDefaultBaseRef({\n            projectWorkspaceDefaultRef: workspace.defaultRef,\n            projectWorkspaceRepoRef: workspace.repoRef,\n          }),\n        }, workspaceDiffQuerySchema.parse(params));\n      }\n\n      const workspace = await ctx.executionWorkspaces.get(workspaceId, companyId);\n      if (!workspace) {\n        throw new Error(\"Workspace not found\");\n      }\n      let projectWorkspaceDefaultBaseRef: string | null = null;\n      if (!readOptionalString(workspace.baseRef)) {","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/packages/plugins/plugin-workspace-diff/src/worker.ts#L47-L83","documentation":"Thrown by the workspace-diff plugin (worker.ts:65) in the `project_workspace` branch when `ctx.projects.listWorkspaces(projectId, companyId)` returns a list that contains no workspace whose `id` equals the supplied `workspaceId`. This means the workspace exists in the caller's intent but is not a member of that project under that company.","triggerScenarios":"Calling the diff data source with `entityType: \"project_workspace\"`, a valid projectId/companyId, and a workspaceId that is not among the project's workspaces — e.g. a workspace id from a different project, a stale id after the workspace was removed, or a cross-company id.","commonSituations":"A workspace was deleted or reassigned to another project but the UI/agent still holds the old id; or a workspaceId from an execution-workspace context is mistakenly used in a project_workspace diff request.","solutions":["Confirm the workspaceId belongs to the given projectId by listing workspaces first, or refresh the workspace selector.","If the workspace was removed, clear the selection and let the user/agent pick a current one.","Switch entityType to the execution-workspace path if the id is actually an execution workspace, not a project workspace."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify the workspace is a member of the project before requesting the diff.\nasync function workspaceBelongsToProject(ctx, projectId, companyId, workspaceId) {\n  const workspaces = await ctx.projects.listWorkspaces(projectId, companyId);\n  return workspaces.some((w) => w.id === workspaceId);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await ctx.data.fetch(\"workspace-diff\", params);\n} catch (err) {\n  if (err instanceof Error && err.message === \"Workspace not found\") {\n    // refresh the project workspace list and re-prompt selection\n  } else throw err;\n}","preventionTips":["Refresh the workspace list when a stale-id error appears.","Pass workspaceId only from a freshly-fetched project workspace list.","Use execution-workspace entityType for non-project ids."],"tags":["plugin","workspace-diff","not-found","project-workspace","git"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}