toeverything/AFFiNE · error · Error

Input is not a service identifier.

Error message

Input is not a service identifier.

What it means

parseIdentifier accepts only existing identifier objects or constructors and throws 'Input is not a service identifier.' for anything else, normalizing all DI lookups to IdentifierValue and catching garbage keys early.

Source

Thrown at packages/common/infra/src/framework/core/identifier.ts:112

/**
 * Convert the constructor into a ServiceIdentifier.
 * As we always deal with ServiceIdentifier in the DI container.
 *
 * @internal
 */
export function createIdentifierFromConstructor<T extends Component>(
  target: Type<T>
): Identifier<T> {
  return createIdentifier<T>(`${target.name}${stableHash(target)}`);
}

export function parseIdentifier(input: any): IdentifierValue {
  if (input.identifierName) {
    return input as IdentifierValue;
  } else if (typeof input === 'function' && input.name) {
    return createIdentifierFromConstructor(input);
  } else {
    throw new Error('Input is not a service identifier.');
  }
}

View on GitHub (pinned to b4c8548c09)

Solutions

  1. Pass a service identifier created by the framework's identifier helpers, not a plain string or class.
  2. Check the call site and replace the invalid input with the correct identifier export.
  3. Verify the identifier import comes from the module that defines the service.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at packages/common/infra/src/framework/core/identifier.ts:112 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18). Data as JSON: /api/errors/c146ebb22ec1c9f0. Report an issue: GitHub.