{"record":{"id":"db03caacacca1130","repo":"nexu-io/open-design","slug":"flag-key-requires-a-value","errorCode":null,"errorMessage":"flag --${key} requires a value","messagePattern":"flag --(.+?) requires a value","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/daemon/src/cli.ts","lineNumber":1760,"sourceCode":"    const eq = a.indexOf('=');\n    const key = eq >= 0 ? a.slice(2, eq) : a.slice(2);\n    if (knownFlags.size > 0 && !knownFlags.has(key)) {\n      throw new Error(\n        `unknown flag: --${key}. Run with --help for the list of accepted flags.`,\n      );\n    }\n    if (eq >= 0) {\n      out[key] = a.slice(eq + 1);\n      continue;\n    }\n    if (booleanFlags.has(key)) {\n      out[key] = true;\n      continue;\n    }\n    if (stringFlags.has(key)) {\n      const next = argv[i + 1];\n      if (next == null) {\n        throw new Error(`flag --${key} requires a value`);\n      }\n      out[key] = next;\n      i++;\n      continue;\n    }\n    const next = argv[i + 1];\n    if (next != null && !next.startsWith('--')) {\n      out[key] = next;\n      i++;\n    } else {\n      out[key] = true;\n    }\n  }\n  return out;\n}\n\nfunction positionalArgs(argv, stringFlags = new Set()) {\n  const out = [];","sourceCodeStart":1742,"sourceCodeEnd":1778,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/cli.ts#L1742-L1778","documentation":"Thrown by parseFlags when a declared string flag is the last argv token, so it has no following token to consume as its value. Boolean flags do not need a value; this fires only for flags in the string set.","triggerScenarios":"Invoking an `od` subcommand with a string flag at the end of the args without a value, e.g. `od automation create --name` (no following value) or `od brand rebuild --id`.","commonSituations":"Truncated copy-paste of a command; a shell that swallowed the value via unquoted whitespace; an env-var substitution that expanded to empty and was then dropped; forgetting the value entirely.","solutions":["Provide a value as the next token: `--name <value>`.","Use the `--key=value` form which keeps flag and value in one token.","If the value comes from an env var, default it inside the shell so it is never empty.","Re-run with --help to confirm which flags are string flags requiring a value."],"exampleFix":"# before\nod automation create --name\n# after\nod automation create --name daily-brand-report\n# or\nod automation create --name=daily-brand-report","handlingStrategy":"validation","validationCode":"// in wrapper scripts, ensure every string flag has a value\nfor (let i = 0; i < argv.length; i++) {\n  if (argv[i].startsWith('--') && !argv[i].includes('=')) {\n    const key = argv[i].slice(2);\n    if (STRING_FLAGS.has(key) && !argv[i + 1]) {\n      throw new Error(`flag --${key} requires a value`);\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer the `--key=value` form so flag and value stay in one token.","Default env-var-derived values in the shell so they are never empty.","Re-run with --help to confirm which flags are string flags."],"tags":["cli","argument-parsing","flag-validation"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}