{"record":{"id":"380585eff2f4835b","repo":"nanocoai/nanoclaw","slug":"invalid-args","errorCode":"invalid-args","errorMessage":"${errMsg(e)}","messagePattern":"\\$\\{errMsg\\(e\\)\\}","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/dispatch.ts","lineNumber":172,"sourceCode":"      .join(' ');\n\n    await requestApproval({\n      session,\n      agentName,\n      action: 'cli_command',\n      payload: { frame: { id: req.id, command: req.command, args: req.args }, callerContext: ctx },\n      title: `CLI: ${req.command}`,\n      question: `Agent \"${agentName}\" wants to run:\\n\\`ncl ${req.command}${argSummary ? ' ' + argSummary : ''}\\``,\n    });\n\n    return err(req.id, 'approval-pending', 'Approval request sent to admin. You will be notified of the result.');\n  }\n\n  let parsed: unknown;\n  try {\n    parsed = cmd.parseArgs(req.args);\n  } catch (e) {\n    return err(req.id, 'invalid-args', errMsg(e));\n  }\n\n  try {\n    let data = await cmd.handler(parsed, ctx);\n\n    // Post-handler group-scope enforcement. Applies only to the auto-generated\n    // `list` / `get` handlers (`cmd.generic`), which return raw DB rows carrying\n    // the resource's `scopeField`:\n    //   - `list` → drop rows that don't belong to the caller's agent group\n    //              (covers `groups list`, where the generic list handler ignores\n    //              the auto-filled `--id`)\n    //   - `get`  → reject if the single row belongs to another group\n    // Custom operations return ad-hoc shapes (e.g. `groups config get` → a config\n    // object with no `id`) and are NOT checked here — they would be falsely\n    // rejected, and they're already pinned to the caller's group by the\n    // pre-handler `--id` auto-fill (groups/destinations) or gated behind approval,\n    // so they can't reach another group's data anyway.\n    if (ctx.caller === 'agent' && cmd.resource && cmd.generic) {","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/nanocoai/nanoclaw/blob/294ef2aee85218b23ad30eda9dfe10e590b54a8c/src/cli/dispatch.ts#L154-L190","documentation":"The command's argument parser (`cmd.parseArgs`) threw while validating the request args — a required flag missing, an unknown flag, or a value of the wrong type/shape. The thrown message is returned verbatim with code `invalid-args`, so the exact parse problem is in the message.","triggerScenarios":"`ncl wirings create` without required flags; passing a non-UUID where an id is expected; booleans given as strings in unexpected positions; JSON args with wrong field types from an agent-built command line.","commonSituations":"Agent constructs ncl argv from chat text and drops or mangles flags; shell quoting eating a value; using flags from an older version's syntax after a resource definition changed.","solutions":["Read the message — it names the offending flag/type","Run `ncl <resource> <verb> help` to see the exact accepted flags for this build","Fix quoting (quote values with spaces; avoid shell-splitting JSON) and re-run","If flags changed, update scripts/agent instructions to the current help output"],"exampleFix":"// before\nncl wirings create --messaging-group\n// after\nncl wirings create --messaging-group <mg-id> --agent-group <ag-id>","handlingStrategy":"validation","validationCode":"const help = await runNcl(`${resource} ${verb} help`);\n// build args strictly from the flags listed in help; drop unknown keys\nconst args = pick(knownFlagsOnly(rawArgs, help));","typeGuard":"function hasRequiredFlags(args: Record<string, unknown>, required: string[]): boolean {\n  return required.every(k => args[k] !== undefined && args[k] !== null && args[k] !== '');\n}","tryCatchPattern":"On code === 'invalid-args', parse the returned message to identify the flag, correct, and re-run once; surface the message verbatim to the operator if it persists.","preventionTips":["Shell-quote every flag value, especially ids and JSON","Run `<verb> help` when scripting new commands","Validate required flags client-side before dispatch"],"tags":["cli","ncl","invalid-args","validation"],"backgroundTag":"command-argument-validation-failed","analyzedSha":"294ef2aee85218b23ad30eda9dfe10e590b54a8c","analyzedAt":"2026-08-28T13:59:10.357Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}