{"record":{"id":"20df3882159c71bc","repo":"nanocoai/nanoclaw","slug":"def-name-id-is-required","errorCode":null,"errorMessage":"${def.name} id is required","messagePattern":"(.+?) id is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/crud.ts","lineNumber":220,"sourceCode":"      if (column) {\n        filters.push(`${k} = ?`);\n        params.push(coerceListFilter(column, v));\n      }\n    }\n    const where = filters.length > 0 ? ` WHERE ${filters.join(' AND ')}` : '';\n    params.push(limit);\n    // Newest first: without an ORDER BY the LIMIT silently hides the most\n    // recently inserted rows once a table outgrows it (bit `sessions list`\n    // past 200 sessions — a just-created session was invisible).\n    return getDb().all(`SELECT ${cols} FROM ${def.table}${where} ORDER BY ${listOrder(def)} LIMIT ?`, ...params);\n  };\n}\n\nfunction genericGet(def: ResourceDef) {\n  const cols = visibleColumns(def).join(', ');\n  return async (args: Record<string, unknown>) => {\n    const id = args.id as string;\n    if (!id) throw new Error(`${def.name} id is required`);\n    const row = await getDb().get(`SELECT ${cols} FROM ${def.table} WHERE ${def.idColumn} = ?`, id);\n    if (!row) throw new Error(`${def.name} not found: ${id}`);\n    return row;\n  };\n}\n\nfunction genericCreate(def: ResourceDef) {\n  return async (args: Record<string, unknown>) => {\n    const values: Record<string, unknown> = {};\n\n    // Pass 1: generated columns + explicit caller args only. Static defaults\n    // wait until after resolveDefaults so the hook sees exactly what the\n    // caller provided and a static default never pre-empts context-aware\n    // resolution.\n    for (const col of def.columns) {\n      if (col.generated) {\n        if (col.name === def.idColumn) {\n          values[col.name] = randomUUID();","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/nanocoai/nanoclaw/blob/294ef2aee85218b23ad30eda9dfe10e590b54a8c/src/cli/crud.ts#L202-L238","documentation":"Thrown by genericGet in src/cli/crud.ts when a `<resource> get` command is invoked without an --id value. Every generic get handler requires the row's id (the resource's idColumn) to locate the record. This is a usage error from the ncl dispatcher, not a DB failure.","triggerScenarios":"Running `ncl <resource> get` with no --id, or with --id set to an empty string (e.g. `--id \"\"` from an unset shell variable).","commonSituations":"Shell scripts passing $ID when the variable is empty; assuming get without id lists rows (use `list` instead).","solutions":["Pass the id: `ncl <resource> get --id <value>`","If you meant to browse, use `ncl <resource> list`","Guard scripts: check the id variable is non-empty before invoking ncl"],"exampleFix":"# before\nncl groups get\n# after\nncl groups get --id my-group","handlingStrategy":"validation","validationCode":"if (!id || !id.trim()) { console.error('id required'); process.exit(1); }","typeGuard":"function hasId(args: Record<string, unknown>): args is { id: string } {\n  return typeof args.id === 'string' && args.id.length > 0;\n}","tryCatchPattern":"try { await nclGet(id) } catch (e) { if ((e as Error).message.endsWith('id is required')) printUsage(); else throw e; }","preventionTips":["Always resolve the id via list before calling get","Reject empty id variables early in shell scripts"],"tags":["cli","missing-argument","crud"],"backgroundTag":"missing-required-argument","analyzedSha":"294ef2aee85218b23ad30eda9dfe10e590b54a8c","analyzedAt":"2026-08-28T13:59:10.357Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}