toeverything/AFFiNE · error · Error

Invalid dependency

Error message

Invalid dependency

What it means

dependenciesToFactory throws 'Invalid dependency' when an array-form dependency declaration does not contain exactly one element, catching malformed DI dependency metadata at component registration time.

Source

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

    return this;
  };
}

/**
 * Convert dependencies definition to a factory function.
 */
function dependenciesToFactory(
  cls: any,
  deps: any[] = []
): ComponentFactory<any> {
  return (provider: FrameworkProvider) => {
    const args = [];
    for (const dep of deps) {
      let isAll;
      let identifier;
      if (Array.isArray(dep)) {
        if (dep.length !== 1) {
          throw new Error('Invalid dependency');
        }
        isAll = true;
        identifier = dep[0];
      } else {
        isAll = false;
        identifier = dep;
      }
      if (isAll) {
        args.push(Array.from(provider.getAll(identifier).values()));
      } else {
        args.push(provider.get(identifier));
      }
    }
    if (isConstructor(cls)) {
      return new cls(...args, provider);
    } else {
      return cls(...args, provider);
    }

View on GitHub (pinned to b4c8548c09)

Solutions

  1. Ensure every entry in the dependency list is a valid service identifier.
  2. Fix imports so dependencies reference the identifier, not an implementation or undefined value.
  3. Check for circular or missing imports that leave a dependency undefined.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/common/infra/src/framework/core/framework.ts:493 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/5bafc0520fac1f2d. Report an issue: GitHub.