toeverything/AFFiNE · error · BlockSuiteError

ValueNotExists

ValueNotExists

Error message

Extension scope ${scope} not found

What it means

ExtensionManager.get(scope) triggers _build(scope), which runs every provider's setup() giving each a chance to register extensions for that scope. If after build no extensions were registered for the scope (the map has no entry) it throws ValueNotExists. Note the method also deletes a pre-existing scope entry before rebuilding, so a provider that does not re-register leaves the scope empty.

Source

Thrown at blocksuite/affine/ext-loader/src/manager.ts:103

    return context;
  };

  /**
   * Retrieves all extensions registered for a specific scope.
   * It triggers the build process.
   *
   * @param scope - The scope to retrieve extensions for
   * @returns An array of extensions registered for the specified scope
   * @throws {BlockSuiteError} If the scope is not found
   */
  get(scope: Scope) {
    if (this._extensions.has(scope)) {
      this._extensions.delete(scope);
    }
    this._build(scope);
    const extensionSet = this._extensions.get(scope);
    if (!extensionSet) {
      throw new BlockSuiteError(
        BlockSuiteError.ErrorCode.ValueNotExists,
        `Extension scope ${scope} not found`
      );
    }
    return Array.from(extensionSet);
  }

  /**
   * Configures a specific provider with new options.
   * Can update existing configuration or remove it entirely.
   * Triggers a rebuild of the provider instance when configuration changes.
   *
   * @typeParam T - The type of configuration options for the provider
   * @param provider - The provider class to configure
   * @param options - New configuration options or a function to update existing options
   */
  configure<T extends Empty>(
    provider: typeof BaseExtensionProvider<Scope, T>,

View on GitHub (pinned to 26c515e050)

Solutions

  1. Confirm the scope string matches what providers register under.
  2. Ensure at least one provider's setup() calls context.register() for the requested scope.
  3. Check configure() calls did not disable the only provider for that scope.
Defensive patterns

Strategy: validation

Validate before calling

manager.get(scope); // ensure at least one provider's setup() calls context.register() for this scope before calling get()

Type guard

const scopeRegistered = (m: ExtensionManager<string>, scope: string): boolean => { try { return m.get(scope as never).length > 0; } catch { return false; } };

Try / catch

try { const exts = manager.get(scope); } catch (e) { if (e instanceof BlockSuiteError && e.code === BlockSuiteError.ErrorCode.ValueNotExists) { /* scope misconfigured — check providers */ } }

Prevention

When it happens

Trigger: Calling get(scope) for a scope that no provider's setup() registers into; or configuring a provider so it no longer registers (e.g. removing its options) then calling get() on a scope it used to populate.

Common situations: Mistyped/unknown scope string; provider misconfiguration that skips registration; ordering issue where get() is called before providers are configured.

Related errors


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