{"record":{"id":"523e8fba4e58407b","repo":"toeverything/AFFiNE","slug":"doc-not-found-523e8f","errorCode":"doc_not_found","errorMessage":"Doc ${docId} under Space ${spaceId} not found.","messagePattern":"Doc (.+?) under Space (.+?) not found\\.","errorType":"exception","errorClass":"DocNotFound","httpStatus":404,"severity":"error","filePath":"packages/backend/server/src/core/workspaces/resolvers/doc.ts","lineNumber":366,"sourceCode":"      );\n    }\n  }\n\n  @ResolveField(() => WorkspaceDocMeta, {\n    description: 'Cloud page metadata of workspace',\n    complexity: 2,\n    deprecationReason: 'use [WorkspaceType.doc] instead',\n  })\n  async pageMeta(\n    @CurrentUser() me: CurrentUser,\n    @Parent() workspace: WorkspaceType,\n    @Args('pageId') pageId: string\n  ) {\n    await this.ac.user(me.id).doc(workspace.id, pageId).assert('Doc.Read');\n\n    const metadata = await this.models.doc.getAuthors(workspace.id, pageId);\n    if (!metadata) {\n      throw new DocNotFound({ spaceId: workspace.id, docId: pageId });\n    }\n\n    return {\n      createdAt: metadata.createdAt,\n      updatedAt: metadata.updatedAt,\n      createdBy: metadata.createdByUser || null,\n      updatedBy: metadata.updatedByUser || null,\n    };\n  }\n\n  @ResolveField(() => [DocType], {\n    description: 'Get public docs of a workspace',\n    complexity: 2,\n  })\n  async publicDocs(@Parent() workspace: WorkspaceType) {\n    return this.models.doc.findPublics(workspace.id);\n  }\n","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/26c515e050211269e911f7d9cfe162a26c83ed98/packages/backend/server/src/core/workspaces/resolvers/doc.ts#L348-L384","documentation":"Thrown by the deprecated WorkspaceType.pageMeta resolver when this.models.doc.getAuthors(workspace.id, pageId) returns null - the doc has no author metadata row, so the page effectively does not exist in this workspace. DocNotFound is a resource_not_found error carrying spaceId and docId.","triggerScenarios":"Querying the pageMeta field on a workspace for a pageId that was never created, was deleted, or whose metadata row is missing; access control passed (Doc.Read) but the underlying author record is absent.","commonSituations":"Stale client referencing a docId that was removed; sync race where the doc exists in the updates table but not in the authors/materialized view; deleted page still cached on the client; wrong pageId typed in.","solutions":["Switch to the non-deprecated WorkspaceType.doc resolver (the resolver is marked deprecated in favor of [WorkspaceType.doc]).","Confirm the pageId exists in the workspace (e.g. via the doc list) before requesting metadata.","If the row is genuinely missing, trigger a doc re-index/rebuild for that workspace.","Handle the error gracefully in the UI and refresh the doc list."],"exampleFix":"# before\nquery { workspace { pageMeta(pageId: $id) { createdAt } } }\n\n# after - use the non-deprecated resolver\nquery { workspace { doc(workspaceId: $wid, docId: $id) { ... } } }","handlingStrategy":"validation","validationCode":"// Verify the page exists before resolving its metadata\nconst exists = await gql.docExists(workspaceId, pageId);\nif (!exists) throw new Error('Page does not exist - skip pageMeta');","typeGuard":"function isDocNotFound(e: unknown): boolean {\n  return (\n    typeof e === 'object' &&\n    e !== null &&\n    (e as any).extensions?.code === 'doc_not_found'\n  );\n}","tryCatchPattern":"try {\n  return await gql.pageMeta(workspaceId, pageId);\n} catch (e) {\n  if (isDocNotFound(e)) {\n    // page was deleted; refresh the doc list and drop the stale reference\n    await refetchDocList();\n    return null;\n  }\n  throw e;\n}","preventionTips":["Prefer the non-deprecated WorkspaceType.doc resolver over pageMeta.","Drop stale pageId references from client state on deletion events.","Make metadata fields nullable in the UI to tolerate missing pages."],"tags":["graphql","doc","not-found","deprecated"],"backgroundTag":null,"analyzedSha":"26c515e050211269e911f7d9cfe162a26c83ed98","analyzedAt":"2026-08-12T13:15:16.447Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}