{"record":{"id":"c767b0bb71cdc612","repo":"tinyhumansai/openhuman","slug":"missing-value-for-arg","errorCode":null,"errorMessage":"missing value for ${arg}","messagePattern":"missing value for (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/debug/agent-prepare-context-audit.mjs","lineNumber":119,"sourceCode":"    queries: [],\n    raw: false,\n    scoutPromptFile: \"\",\n    threadPrefix: `apc-audit-${randomBytes(3).toString(\"hex\")}`,\n    seedTranscript: true,\n    maxPrintChars: 4000,\n    rpcTimeoutMs: 600_000,\n    spawnCore: false,\n    keepWorkspace: false,\n    json: false,\n    verbose: false,\n    coreUrlExplicit: Boolean(process.env.OPENHUMAN_CORE_RPC_URL),\n    workspaceExplicit: Boolean(process.env.OPENHUMAN_WORKSPACE),\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 === undefined) throw new Error(`missing value for ${arg}`);\n      return value;\n    };\n    switch (arg) {\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        opts.workspaceExplicit = true;\n        break;\n      case \"--model\":\n        opts.model = next();\n        break;\n      case \"--query\":","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/a221052e0df5b1f7598fceba7329fd1af95d6699/scripts/debug/agent-prepare-context-audit.mjs#L101-L137","documentation":"parseArgs() in scripts/debug/agent-prepare-context-audit.mjs walks argv with a next() helper that consumes the following token for value-taking options (--core-url, --token, --workspace, --model, --query, --scout-prompt-file, --thread-prefix, --max-print-chars, --rpc-timeout-ms). When the option is the last token on the command line, argv[++i] is undefined and it throws 'missing value for <flag>'.","triggerScenarios":"Invoking the audit script with a value-taking flag at the end of the command with nothing after it, e.g. `node scripts/debug/agent-prepare-context-audit.mjs --token` or `... --query`. Also triggered when a quoted empty-string argument is stripped by shell misquoting and the next token is genuinely absent.","commonSituations":"Incrementally building a long debug command line and forgetting to paste the value; copy-pasting from docs where the placeholder value was on a wrapped line; CI scripts concatenating flag arrays where an undefined env var expands to nothing.","solutions":["Supply the missing value right after the flag: --token <value>","If the flag is unwanted, remove it entirely rather than leaving it dangling","For values that may be empty or env-derived, pass them via environment (OPENHUMAN_CORE_TOKEN etc.) instead of the flag form"],"exampleFix":"# before\n$ node scripts/debug/agent-prepare-context-audit.mjs --token\nError: missing value for --token\n\n# after\n$ node scripts/debug/agent-prepare-context-audit.mjs --token \"$OPENHUMAN_CORE_TOKEN\"","handlingStrategy":"validation","validationCode":"// Lint argv before executing: every value-taking flag must have a following token\nconst VALUE_FLAGS = new Set([\"--core-url\", \"--token\", \"--workspace\", \"--model\", \"--query\", \"--scout-prompt-file\", \"--thread-prefix\", \"--max-print-chars\", \"--rpc-timeout-ms\"]);\nfor (let i = 0; i < argv.length; i++) {\n  if (VALUE_FLAGS.has(argv[i]) && (i + 1 >= argv.length || argv[i + 1].startsWith(\"--\"))) {\n    console.error(`${argv[i]} requires a value`); process.exit(2);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Quote flag values: --token \"$TOKEN\" so empty/unset env vars fail loudly at the value check, not silently","Prefer environment variables (OPENHUMAN_CORE_TOKEN, OPENHUMAN_WORKSPACE) for optional values — they cannot dangle","Dry-run long commands with echo before executing them in CI"],"tags":["cli","arguments","usage"],"backgroundTag":null,"analyzedSha":"a221052e0df5b1f7598fceba7329fd1af95d6699","analyzedAt":"2026-08-16T12:47:06.542Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}