affaan-m/ECC · error · Error

Work item not found: ${id}

Error message

Work item not found: ${id}

What it means

Thrown by the 'show' command when store.getWorkItemById(id) returns null, meaning no row in the SQLite state store matches the given local id. The id resolved fine (it is non-empty) but nothing was ever upserted under it. The id is interpolated into the message verbatim so typos are visible.

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 01e15490f0)

Solutions

  1. List first to confirm the exact id: `node scripts/work-items.js list` (or --json to grep).
  2. Check you are using the same --db path where the item was created.
  3. For GitHub items, the id has the form github-<owner-name-repo>-<pr|issue>-<number>; copy it from list output.

Example fix

// before
node scripts/work-items.js show "Refactor state store"

// after
node scripts/work-items.js list --json
# find the real id, then:
node scripts/work-items.js show refactor-state-store
Defensive patterns

Strategy: try-catch

Validate before calling

function showOrError(store, id) {
  const item = store.getWorkItemById(id);
  if (!item) return { ok: false, error: `Work item not found: ${id}` };
  return { ok: true, item };
}

Type guard

function isStoredWorkItem(value) {
  return Boolean(value && typeof value === 'object' && typeof value.id === 'string' && typeof value.title === 'string');
}

Try / catch

try {
  // show flow
} catch (error) {
  if (/^Work item not found:/.test(error.message)) {
    // recover: list items, suggest closest id, or exit gracefully
  } else {
    throw error;
  }
}

Prevention

When it happens

Trigger: Calling `show <id>` for an id that was never created, was created in a different --db database, or was mistyped. The store is created from options.dbPath or the default HOME-based location, so pointing at a different db yields 'not found' for items that exist elsewhere.

Common situations: Typos in the id; pointing at the wrong database (--db not set, or set to a stale path); the item was synced under a generated github-... id and you typed a human-readable name instead; the item was closed pruned.

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/8d5db2c8e8fabacf. Report an issue: GitHub.