{"record":{"id":"057960ebd12aeb68","repo":"nexu-io/open-design","slug":"design-system-backing-project-is-unavailable","errorCode":null,"errorMessage":"design system backing project is unavailable","messagePattern":"design system backing project is unavailable","errorType":"exception","errorClass":"Error","httpStatus":500,"severity":"error","filePath":"apps/daemon/src/design-systems/team-project-share.ts","lineNumber":96,"sourceCode":"  return error;\n}\n\n/**\n * Build the exact-Workspace project half of the linked-resource saga.\n * Authority is checked before the coordinator publishes the design system,\n * and each remote-project/local-projection pair compensates itself before\n * rejecting.\n */\nexport function createDesignSystemBackingProjectPreparer(\n  options: CreateDesignSystemBackingProjectPreparerOptions,\n): CreateLinkedProjectTeamResourceShareServiceOptions['prepare'] {\n  return async (resourceId, scope) => {\n    let projectId = (await options.resolveProjectId(resourceId, scope))?.trim() ?? '';\n    if ((!projectId || !options.projectExists(projectId)) && options.ensureProjectId) {\n      projectId = (await options.ensureProjectId(resourceId, scope))?.trim() ?? '';\n    }\n    if (!projectId || !options.projectExists(projectId)) {\n      throw new Error('design system backing project is unavailable');\n    }\n    const workspaceId = scope.principal.teamId;\n    const memberId = scope.principal.memberId;\n    const binding = options.getProjectBinding(projectId);\n    if (binding?.workspaceId && binding.workspaceId !== workspaceId) {\n      throw new Error('design system backing project belongs to another workspace');\n    }\n    if (binding?.createdByWorkspaceMemberId !== memberId) {\n      throw new TeamResourceShareForbiddenError();\n    }\n    options.onPrepared?.({ resourceId, projectId, scope });\n    return {\n      projectId,\n      transition: async (visibility) => {\n        if (visibility === 'team') {\n          const published = await options.publishProject(projectId, scope);\n          if (published.version == null) {\n            throw new Error('design system backing project publish failed');","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/design-systems/team-project-share.ts#L78-L114","documentation":"Thrown by the design-system backing project preparer when neither `resolveProjectId` nor (if provided) `ensureProjectId` returns a usable project id, or when the returned id fails `projectExists`. The preparer is the exact-Workspace authorization gate before any Team hub mutation, so a missing backing project aborts the share rather than publishing an orphan design system.","triggerScenarios":"Calling `share` on a linked design-system resource whose backing project was deleted, never created, or whose resolver returned null and `ensureProjectId` is not configured (or also returned null/empty).","commonSituations":"The backing project row was removed out-of-band while the design system record remained. Auto-creation (`ensureProjectId`) is disabled in the deployment. A resolver bug returns null for a resource that should have a project. Database/SQLite issues making `projectExists` return false.","solutions":["Verify the backing project for the design system still exists in the project store.","If auto-creation is intended, ensure `ensureProjectId` is wired in the preparer options and can materialize the project under the request's workspace identity.","Check the resolver (`resolveProjectId`) returns the correct project id for the resource id and scope.","Investigate SQLite/project-store health if the project exists in the hub but `projectExists` returns false."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before sharing, confirm the backing project resolves and exists:\nconst projectId = await resolveProjectId(resourceId, scope);\nif (!projectId || !projectExists(projectId)) {\n  if (!ensureProjectId) throw new Error('backing project missing and auto-create is disabled');\n  const ensured = await ensureProjectId(resourceId, scope);\n  if (!ensured || !projectExists(ensured)) {\n    throw new Error('cannot prepare backing project for share');\n  }\n}\nawait share(resourceId, scope);","typeGuard":null,"tryCatchPattern":"try {\n  await linkedShare.share(resourceId, scope);\n} catch (err) {\n  if (err instanceof Error && /backing project is unavailable/.test(err.message)) {\n    // re-create the backing project or wire ensureProjectId, then retry\n  }\n  throw err;\n}","preventionTips":["Wire `ensureProjectId` in the preparer so missing backing projects are materialized lazily.","Monitor for out-of-band project deletion so design-system records don't outlive their projects.","Run resolver/exists checks before offering the share action in the UI."],"tags":["team","design-system","workspace","share","project","authorization"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}