{"record":{"id":"501ce7d8fb2aca4c","repo":"tinyhumansai/openhuman","slug":"missing-value-for-arg-501ce7","errorCode":null,"errorMessage":"missing value for ${arg}","messagePattern":"missing value for (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/debug/harness-subagent-rpc-audit.mjs","lineNumber":81,"sourceCode":"    agentId: \"researcher\",\n    model: \"\",\n    providerMode: \"openhuman-backend\",\n    rpcTimeoutMs: 600_000,\n    spawnWaitMs: 120_000,\n    settleWaitMs: 60_000,\n    spawnCore: false,\n    isolatedWorkspace: false,\n    keepWorkspace: false,\n    verbose: false,\n    coreUrlExplicit: Boolean(process.env.OPENHUMAN_CORE_RPC_URL),\n    agentIdExplicit: false,\n  };\n\n  for (let i = 0; i < argv.length; i += 1) {\n    const arg = argv[i];\n    const next = () => {\n      const value = argv[++i];\n      if (!value) throw new Error(`missing value for ${arg}`);\n      return value;\n    };\n    switch (arg) {\n      case \"--scenario\":\n        opts.scenario = next();\n        break;\n      case \"--core-url\":\n        opts.coreUrl = next();\n        opts.coreUrlExplicit = true;\n        break;\n      case \"--token\":\n        opts.token = next();\n        break;\n      case \"--workspace\":\n        opts.workspace = next();\n        break;\n      case \"--task-key\":\n        opts.taskKey = next();","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/a221052e0df5b1f7598fceba7329fd1af95d6699/scripts/debug/harness-subagent-rpc-audit.mjs#L63-L99","documentation":"Argument-parser error in harness-subagent-rpc-audit's next() helper. When a value-taking flag (--scenario, --core-url, --token, --workspace, --task-key, --agent-id, --model, --provider-mode, --rpc-timeout-ms, --spawn-wait-ms, --settle-wait-ms) is the last token on the command line, argv[++i] is undefined (or an empty string) and the parser throws naming the orphaned flag.","triggerScenarios":"A value flag placed last (`... --scenario` with nothing after), shell line-wrapping that drops the value, or an empty-string value from an unexpanded variable (`--task-key \"$TK\"` with TK unset under set -u quirks or plain empty). Note a following flag like `--scenario --verbose` does NOT trigger this — it is silently consumed as the value and fails later validation instead.","commonSituations":"Copy-pasted commands with a truncated tail; CI YAML folding a long command across lines; quoting mistakes that pass \"\" as the value.","solutions":["Re-run with the flag followed by its value: `--scenario async-steer`","Print usage (`-h`) to confirm which flags take values","If the value comes from a variable, verify it is non-empty before invoking (`: \"${VAR:?}\"`)"],"exampleFix":"# before\nnode scripts/debug/harness-subagent-rpc-audit.mjs --spawn-core --isolated-workspace --scenario\n\n# after\nnode scripts/debug/harness-subagent-rpc-audit.mjs --spawn-core --isolated-workspace --scenario async-steer","handlingStrategy":"validation","validationCode":"const VALUE_FLAGS = new Set([\"--scenario\",\"--core-url\",\"--token\",\"--workspace\",\"--task-key\",\"--agent-id\",\"--model\",\"--provider-mode\",\"--rpc-timeout-ms\",\"--spawn-wait-ms\",\"--settle-wait-ms\"]);\nconst argv = process.argv.slice(2);\nfor (let i = 0; i < argv.length; i++) {\n  if (VALUE_FLAGS.has(argv[i]) && (argv[i + 1] === undefined || argv[i + 1] === \"\")) {\n    console.error(`${argv[i]} needs a value`); process.exit(2);\n  }\n  if (VALUE_FLAGS.has(argv[i])) i++; // skip the value\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Quote variable expansions and default them: --task-key \"${TK:-audit}\"","Run -h once when adding flags to a wrapper script"],"tags":["cli","arguments","validation"],"backgroundTag":null,"analyzedSha":"a221052e0df5b1f7598fceba7329fd1af95d6699","analyzedAt":"2026-08-16T12:47:06.542Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}