affaan-m/ECC · error

An install component ID is required

Error message

An install component ID is required

What it means

getInstallComponent() requires a non-empty component ID. It normalizes the argument with String(componentId || '').trim() and throws when the result is empty, because looking up nothing would otherwise be an ambiguous no-op.

Solutions

  1. Pass a concrete, non-empty component ID string
  2. Trim/validate the ID before calling; skip the call entirely when it is empty
  3. If the ID comes from a file or CLI arg, check it is present and fail early with a clearer message
  4. Use listInstallComponents() to discover valid IDs first

Example fix

// before
const id = process.argv[2];
getInstallComponent(id); // throws when no arg
// after
const id = process.argv[2];
if (!id || !id.trim()) {
  throw new Error('Usage: ecc component <component-id>');
}
getInstallComponent(id.trim());
Defensive patterns

Strategy: validation

Validate before calling

if (typeof componentId !== 'string' || !componentId.trim()) {
  throw new Error('componentId must be a non-empty string');
}

Type guard

const hasComponentId = (id) => typeof id === 'string' && id.trim().length > 0;

Try / catch

try {
  const comp = getInstallComponent(componentId);
} catch (err) {
  if (err.message === 'An install component ID is required') {
    console.error('Usage: <tool> component <component-id>');
    process.exitCode = 1;
  } else throw err;
}

Prevention

When it happens

Trigger: Calling getInstallComponent(undefined), getInstallComponent(''), getInstallComponent(' '), or getInstallComponent(null) — typically when an ID variable is unset, an array destructuring missed, or a CLI arg was not provided.

Common situations: A shell variable expanding to empty, a script reading an ID from a JSON field that is missing, or a CLI invocation like `ecc component` without the ID argument.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/e2ce0fbb815e301c. Report an issue: GitHub.

Appendix: source

Thrown at scripts/lib/install-manifests.js:424

      return {
        id: component.id,
        family: component.family,
        description: component.description,
        moduleIds,
        moduleCount: moduleIds.length,
        targets,
      };
    })
    .filter(component => !target || component.targets.includes(target));
}

function getInstallComponent(componentId, options = {}) {
  const manifests = loadInstallManifests(options);
  const normalizedComponentId = String(componentId || '').trim();

  if (!normalizedComponentId) {
    throw new Error('An install component ID is required');
  }

  const component = manifests.componentsById.get(normalizedComponentId);
  if (!component) {
    throw new Error(`Unknown install component: ${normalizedComponentId}`);
  }

  const moduleIds = dedupeStrings(component.modules);
  const modules = moduleIds
    .map(moduleId => manifests.modulesById.get(moduleId))
    .filter(Boolean)
    .map(module => ({
      id: module.id,
      kind: module.kind,
      description: module.description,
      targets: module.targets,
      defaultInstall: module.defaultInstall,
      cost: module.cost,

View on GitHub (pinned to 8321021c54)