toeverything/AFFiNE · error · NotFoundException

Not Found

Error message

Not Found

What it means

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.

Source

Thrown at packages/backend/server/src/core/workspaces/resolvers/admin.ts:445

  ] as const),
  InputType
) {
  @Field()
  id!: string;
}

@Injectable()
@Admin()
@Resolver(() => AdminWorkspace)
export class AdminWorkspaceResolver {
  constructor(
    private readonly models: Models,
    private readonly url: URLHelper
  ) {}

  private assertCloudOnly() {
    if (env.selfhosted) {
      throw new NotFoundException();
    }
  }

  @Query(() => [AdminWorkspace], {
    description: 'List workspaces for admin',
  })
  async adminWorkspaces(
    @Args('filter', { type: () => ListWorkspaceInput })
    filter: ListWorkspaceInput
  ) {
    this.assertCloudOnly();
    const { rows } = await this.models.workspace.adminListWorkspaces({
      first: filter.first,
      skip: filter.skip,
      keyword: filter.keyword,
      order: this.mapSort(filter.orderBy),
      flags: {
        public: filter.public ?? undefined,

View on GitHub (pinned to 26c515e050)

Solutions

  1. If self-hosted, do not call admin endpoints; they are unsupported there.
  2. If actually on cloud, verify env.selfhosted is not wrongly set true.
  3. Gate the admin UI so it is not rendered on self-hosted builds.

Example fix

// before
if (isAdmin) fetchAdminWorkspaces()
// after
if (isAdmin && !env.selfhosted) fetchAdminWorkspaces()
Defensive patterns

Strategy: type-guard

Validate before calling

const isCloud = !env.selfhosted
if (isCloud) await adminApi.workspaces()

Type guard

function adminEndpointsAvailable(): boolean { return !env.selfhosted }

Try / catch

try { await adminApi.workspaces() } catch (e) {
  if (e instanceof NotFoundException && isSelfHosted) hideAdminUI()
  else throw e
}

Prevention

When it happens

Trigger: Calling any @Admin() adminWorkspace* GraphQL query/mutation on a self-hosted instance where env.selfhosted=true.

Common situations: Admin UI/shell loaded against a self-hosted deployment; a cloud-targeted script run against self-hosted; env.selfhosted wrongly set.

Related errors


AI-assisted analysis of toeverything/AFFiNE@26c515e050 (2026-08-12). Data as JSON: /api/errors/d89a1fd8069cd955. Report an issue: GitHub.