nanocoai/nanoclaw · error

${def.name} not found: ${id}

Error message

${def.name} not found: ${id}

What it means

Thrown by genericGet in src/cli/crud.ts when a SELECT by the resource's idColumn returns no row — the requested record does not exist in the central DB. The id was provided but matched nothing.

Source

Thrown at src/cli/crud.ts:222

        params.push(coerceListFilter(column, v));
      }
    }
    const where = filters.length > 0 ? ` WHERE ${filters.join(' AND ')}` : '';
    params.push(limit);
    // Newest first: without an ORDER BY the LIMIT silently hides the most
    // recently inserted rows once a table outgrows it (bit `sessions list`
    // past 200 sessions — a just-created session was invisible).
    return getDb().all(`SELECT ${cols} FROM ${def.table}${where} ORDER BY ${listOrder(def)} LIMIT ?`, ...params);
  };
}

function genericGet(def: ResourceDef) {
  const cols = visibleColumns(def).join(', ');
  return async (args: Record<string, unknown>) => {
    const id = args.id as string;
    if (!id) throw new Error(`${def.name} id is required`);
    const row = await getDb().get(`SELECT ${cols} FROM ${def.table} WHERE ${def.idColumn} = ?`, id);
    if (!row) throw new Error(`${def.name} not found: ${id}`);
    return row;
  };
}

function genericCreate(def: ResourceDef) {
  return async (args: Record<string, unknown>) => {
    const values: Record<string, unknown> = {};

    // Pass 1: generated columns + explicit caller args only. Static defaults
    // wait until after resolveDefaults so the hook sees exactly what the
    // caller provided and a static default never pre-empts context-aware
    // resolution.
    for (const col of def.columns) {
      if (col.generated) {
        if (col.name === def.idColumn) {
          values[col.name] = randomUUID();
        } else if (col.name.endsWith('_at')) {
          values[col.name] = new Date().toISOString();

View on GitHub (pinned to 294ef2aee8)

Solutions

  1. List ids to confirm: `ncl <resource> list`
  2. Check for typos / trailing whitespace in the id
  3. Verify you're connected to the right install (ncl goes over the Unix socket of the running host)

Example fix

# before
ncl groups get --id mygroup
# after
ncl groups list   # find the real id
ncl groups get --id my-group
Defensive patterns

Strategy: try-catch

Validate before calling

const exists = await runNcl([resource, 'list', '--json']);
if (!exists.some(r => r[idColumn] === id)) skip();

Try / catch

try { const row = await getResource(id); } catch (e) { if ((e as Error).message.includes('not found')) return null; throw e; }

Prevention

When it happens

Trigger: `ncl <resource> get --id <id>` where no row has that id: typo'd id, deleted record, or the wrong install's DB (socket points at another copy).

Common situations: Using an id copied from another NanoClaw install; record was deleted by another admin; slug vs internal id confusion.

Related errors


AI-assisted analysis of nanocoai/nanoclaw@294ef2aee8 (2026-08-28). Data as JSON: /api/errors/8bab601aa8680b59. Report an issue: GitHub.