{"record":{"id":"2043a5a87da5f035","repo":"github/spec-kit","slug":"error-arg-requires-a-value","errorCode":null,"errorMessage":"Error: {arg} requires a value","messagePattern":"Error: (.+?) requires a value","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/python/create_new_feature.py","lineNumber":131,"sourceCode":"    allow_existing = False\n    short_name = \"\"\n    branch_number = \"\"\n    use_timestamp = False\n    rest: list[str] = []\n\n    i = 0\n    while i < len(argv):\n        arg = argv[i]\n        if arg == \"--json\":\n            json_mode = True\n        elif arg == \"--dry-run\":\n            dry_run = True\n        elif arg == \"--allow-existing-branch\":\n            allow_existing = True\n        elif arg in {\"--short-name\", \"--number\"}:\n            if i + 1 >= len(argv) or argv[i + 1].startswith(\"--\"):\n                print(f\"Error: {arg} requires a value\", file=sys.stderr)\n                raise SystemExit(1)\n            i += 1\n            if arg == \"--short-name\":\n                short_name = argv[i]\n            else:\n                branch_number = argv[i]\n        elif arg == \"--timestamp\":\n            use_timestamp = True\n        elif arg in {\"--help\", \"-h\"}:\n            sys.stdout.write(_help_text(argv0))\n            raise SystemExit(0)\n        else:\n            rest.append(arg)\n        i += 1\n\n    description = \" \".join(rest).strip()\n    if not description:\n        if rest:\n            print(","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/github/spec-kit/blob/bf88c9f9a82fa370c7a7257aa2b3cf10b457b65c/scripts/python/create_new_feature.py#L113-L149","documentation":"create_new_feature.py's hand-rolled argv parser requires --short-name and --number to be followed by a value. It rejects the call when the flag is the last argument or the next token starts with '--' (i.e. looks like another flag), printing this error to stderr and exiting with code 1.","triggerScenarios":"Running scripts/python/create_new_feature.py \"desc\" --short-name (flag last), or --short-name --json (value looks like a flag), or forgetting the value entirely: --number without the issue number.","commonSituations":"Shell quoting mistakes where the intended value ends up in a separate argument or is dropped; copy-pasting a command from docs that used a placeholder like <name> the user replaced with nothing; CI scripts constructing the command dynamically with an empty variable producing '--short-name --allow-existing-branch'.","solutions":["Supply a value immediately after the flag: --short-name my-feature or --number 1234.","If the value legitimately starts with '--' (rare), choose a different value — the parser intentionally cannot accept it.","In scripts, guard empty variables before building the command: only append \"--short-name $NAME\" when NAME is non-empty."],"exampleFix":"# before\ncmd=(python create_new_feature.py --short-name --json \"Add login\")\n# after\nname=\"\"\n[ -n \"$name\" ] && cmd+=(--short-name \"$name\")\ncmd+=(--json \"Add login\")","handlingStrategy":"validation","validationCode":"import sys\n\nVALUE_FLAGS = {\"--short-name\", \"--number\"}\n\ndef argv_is_well_formed(argv: list[str]) -> bool:\n    for i, a in enumerate(argv):\n        if a in VALUE_FLAGS:\n            if i + 1 >= len(argv) or argv[i + 1].startswith(\"--\"):\n                return False\n    return True\n\nif not argv_is_well_formed(sys.argv[1:]):\n    sys.exit(\"--short-name/--number each require a non-flag value\")","typeGuard":null,"tryCatchPattern":"try:\n    args = parse_args(argv)\nexcept SystemExit as e:\n    # argparse-style exit(1) on bad flags; inspect stderr message if needed\n    raise","preventionTips":["Always place the value directly after --short-name / --number.","Build CLI invocations conditionally so empty variables never leave a bare flag.","Values starting with '--' are unsupported — choose different values."],"tags":["cli","argument-parsing","shell"],"backgroundTag":null,"analyzedSha":"bf88c9f9a82fa370c7a7257aa2b3cf10b457b65c","analyzedAt":"2026-08-14T19:43:37.150Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}