{"record":{"id":"9c047e7a2e39418c","repo":"toeverything/AFFiNE","slug":"not-found-9c047e","errorCode":"not_found","errorMessage":"Resource not found.","messagePattern":"Resource not found\\.","errorType":"exception","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"packages/backend/server/src/core/workspaces/resolvers/admin.ts","lineNumber":445,"sourceCode":"  ] as const),\n  InputType\n) {\n  @Field()\n  id!: string;\n}\n\n@Injectable()\n@Admin()\n@Resolver(() => AdminWorkspace)\nexport class AdminWorkspaceResolver {\n  constructor(\n    private readonly models: Models,\n    private readonly url: URLHelper\n  ) {}\n\n  private assertCloudOnly() {\n    if (env.selfhosted) {\n      throw new NotFoundException();\n    }\n  }\n\n  @Query(() => [AdminWorkspace], {\n    description: 'List workspaces for admin',\n  })\n  async adminWorkspaces(\n    @Args('filter', { type: () => ListWorkspaceInput })\n    filter: ListWorkspaceInput\n  ) {\n    this.assertCloudOnly();\n    const { rows } = await this.models.workspace.adminListWorkspaces({\n      first: filter.first,\n      skip: filter.skip,\n      keyword: filter.keyword,\n      order: this.mapSort(filter.orderBy),\n      flags: {\n        public: filter.public ?? undefined,","sourceCodeStart":427,"sourceCodeEnd":463,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/backend/server/src/core/workspaces/resolvers/admin.ts#L427-L463","documentation":"AdminWorkspaceResolver.assertCloudOnly throws Nest's NotFoundException whenever env.selfhosted is truthy. Admin GraphQL fields (adminWorkspaces and siblings) deliberately return generic 404 not-found on self-hosted builds so the admin surface is neither usable nor discoverable there.","triggerScenarios":"Invoking any admin* query/mutation guarded by assertCloudOnly on a deployment built or configured with selfhosted=true; also schema-introspecting clients that assume listed admin fields are callable everywhere.","commonSituations":"Self-hosted installs pointed at admin tooling or scripts written for the cloud; a cloud-like deployment where the selfhosted env flag was left/mis-set to true; operators wondering why admin queries 404 despite an admin user account.","solutions":["Do not call admin* resolvers on self-hosted — they are intentionally absent there","If this deployment should be cloud, set the selfhosted env flag to false","Target admin APIs only at the cloud deployment with an admin-authenticated account","In clients, detect this 404 on admin fields and show 'not available on self-hosted' instead of retrying"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// know your deployment before wiring admin tooling\nconst isSelfHosted = await detectSelfHosted(); // e.g. from server capabilities/config endpoint\nif (isSelfHosted) {\n  disableAdminFeatures(); // admin resolvers intentionally 404 there\n} else {\n  mountAdminConsole();\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await adminClient.request(ADMIN_WORKSPACES_QUERY);\n} catch (e) {\n  if (e?.code === 'not_found' && targetIsSelfHosted) {\n    return showAdminUnavailable(); // by design — do not retry\n  }\n  throw e;\n}","preventionTips":["Feature-flag admin UI on the deployment flavor (cloud vs self-hosted)","Never assume introspected schema fields are callable on every build","Set the selfhosted env flag correctly for your deployment type","Document for operators that admin APIs are cloud-only"],"tags":["admin","self-hosted","feature-flag","cloud-only"],"backgroundTag":"cloud-only-feature","analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}