affaan-m/ECC · error · Error

Work item not found

Error message

Work item not found: ${id}

What it means

This error is thrown by the work-items CLI (scripts/work-items.js) when a user requests a specific work item by id (e.g. via the get/show subcommand) but the store has no work item with that id. resolveWorkItemId produced an id string, so the id format was acceptable, but store.getWorkItemById returned null. It is a straightforward lookup miss, not a validation failure.

Solutions

  1. List all existing work items (the list command) and copy the exact id of the item you want.
  2. Verify you are running the script from the same repository/working directory so it reads the intended store file.
  3. Check the id for typos or truncation; ids are matched exactly by store.getWorkItemById.
  4. If the item should exist but does not, re-create it with the create/upsert command, then look it up again.

Example fix

// before
node scripts/work-items.js get 42
// Error: Work item not found: 42

// after
node scripts/work-items.js list          # find the real id
node scripts/work-items.js get wi-0042
Defensive patterns

Strategy: validation

Validate before calling

const items = JSON.parse(execSync('node scripts/work-items.js list --json').toString());
if (!items.some(i => i.id === id)) throw new Error(`id ${id} not in store; run list to see valid ids`);

Try / catch

try {
  execSync(`node scripts/work-items.js get ${id}`, { stdio: 'inherit' });
} catch (e) {
  if (String(e.stderr).includes('Work item not found')) {
    console.error(`Item ${id} does not exist — run list first.`);
  }
}

Prevention

When it happens

Trigger: Running a lookup command (e.g. `node scripts/work-items.js get <id>` or show) where the id passed --id or as a positional resolves to a value that is not present in the work-items store. Happens after the item was deleted, the id was typo'd, or the store file is a different one than the item was written to.

Common situations: Developer typos an id or copies a truncated id from a branch name; item was already closed/deleted by another session; running the script from a different working directory so a different store file is read; stale docs referencing an old id.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at scripts/work-items.js:442

    if (options.command === 'list') {
      const payload = store.listWorkItems({ limit: normalizeLimit(options.limit) });
      if (options.json) {
        console.log(JSON.stringify(payload, null, 2));
      } else {
        printWorkItemList(payload);
      }
      return;
    }

    if (options.command === 'show') {
      const id = resolveWorkItemId(options);
      if (!id) {
        throw new Error('Missing work item id.');
      }
      const item = store.getWorkItemById(id);
      if (!item) {
        throw new Error(`Work item not found: ${id}`);
      }
      if (options.json) {
        console.log(JSON.stringify(item, null, 2));
      } else {
        printWorkItem(item);
      }
      return;
    }

    if (options.command === 'upsert') {
      const id = resolveWorkItemId(options);
      const existing = id ? store.getWorkItemById(id) : null;
      const item = store.upsertWorkItem(buildUpsertPayload(options, existing));
      if (options.json) {
        console.log(JSON.stringify(item, null, 2));
      } else {
        printWorkItem(item);
      }

View on GitHub (pinned to 8321021c54)