{"record":{"id":"d89a1fd8069cd955","repo":"toeverything/AFFiNE","slug":"not-found-d89a1f","errorCode":null,"errorMessage":"Not Found","messagePattern":"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/26c515e050211269e911f7d9cfe162a26c83ed98/packages/backend/server/src/core/workspaces/resolvers/admin.ts#L427-L463","documentation":"Thrown by assertCloudOnly on admin resolver methods: every admin workspace endpoint is gated to cloud deployments and returns 404 on self-hosted (env.selfhosted=true). It is a deliberate access hide, not a missing route.","triggerScenarios":"Calling any @Admin() adminWorkspace* GraphQL query/mutation on a self-hosted instance where env.selfhosted=true.","commonSituations":"Admin UI/shell loaded against a self-hosted deployment; a cloud-targeted script run against self-hosted; env.selfhosted wrongly set.","solutions":["If self-hosted, do not call admin endpoints; they are unsupported there.","If actually on cloud, verify env.selfhosted is not wrongly set true.","Gate the admin UI so it is not rendered on self-hosted builds."],"exampleFix":"// before\nif (isAdmin) fetchAdminWorkspaces()\n// after\nif (isAdmin && !env.selfhosted) fetchAdminWorkspaces()","handlingStrategy":"type-guard","validationCode":"const isCloud = !env.selfhosted\nif (isCloud) await adminApi.workspaces()","typeGuard":"function adminEndpointsAvailable(): boolean { return !env.selfhosted }","tryCatchPattern":"try { await adminApi.workspaces() } catch (e) {\n  if (e instanceof NotFoundException && isSelfHosted) hideAdminUI()\n  else throw e\n}","preventionTips":["Hide admin surfaces on self-hosted.","Keep env.selfhosted correctly configured.","Apply the cloud-only guard at the UI shell level."],"tags":["admin","deployment","cloud-only","self-hosted"],"backgroundTag":null,"analyzedSha":"26c515e050211269e911f7d9cfe162a26c83ed98","analyzedAt":"2026-08-12T13:15:16.447Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}