{"record":{"id":"e12658ba10b9253e","repo":"nodejs/node","slug":"argument-k-concatenated-already-set-n","errorCode":null,"errorMessage":"argument -K / --concatenated already set\\n","messagePattern":"argument -K / --concatenated already set\\\\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/brotli/c/tools/brotli.c","lineNumber":413,"sourceCode":"          continue;\n        } else if (c == 't') {\n          if (command_set) {\n            fprintf(stderr, \"command already set when parsing -t\\n\");\n            return COMMAND_INVALID;\n          }\n          command_set = BROTLI_TRUE;\n          command = COMMAND_TEST_INTEGRITY;\n          continue;\n        } else if (c == 'v') {\n          if (params->verbosity > 0) {\n            fprintf(stderr, \"argument --verbose / -v already set\\n\");\n            return COMMAND_INVALID;\n          }\n          params->verbosity = 1;\n          continue;\n        } else if (c == 'K') {\n          if (concatenated_set) {\n            fprintf(stderr, \"argument -K / --concatenated already set\\n\");\n            return COMMAND_INVALID;\n          }\n          concatenated_set = BROTLI_TRUE;\n          params->allow_concatenated = BROTLI_TRUE;\n          continue;\n        } else if (c == 'V') {\n          /* Don't parse further. */\n          return COMMAND_VERSION;\n        } else if (c == 'Z') {\n          if (quality_set) {\n            fprintf(stderr, \"quality already set\\n\");\n            return COMMAND_INVALID;\n          }\n          quality_set = BROTLI_TRUE;\n          params->quality = 11;\n          continue;\n        }\n        /* o/q/w/C/D/S with parameter is expected */","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/brotli/c/tools/brotli.c#L395-L431","documentation":"The `-K` / `--concatenated` flag tells the brotli CLI to decompress files that are concatenations of multiple brotli streams; it sets `params->allow_concatenated`. A single `concatenated_set` latch guards it, and any second occurrence is a hard error that aborts parsing before any I/O. Brotli refuses ambiguous flag combinations rather than silently picking one.","triggerScenarios":"Passing `-K` twice, or `-K` after `--concatenated` (short and long forms share the same latch), e.g. `brotli -d -K -K in.br` or `brotli --concatenated -K -d in.br`.","commonSituations":"A shell alias or wrapper script appends `-K` unconditionally while the user also typed it; merged copy-pasted command lines; CI matrix generators that concatenate flag lists.","solutions":["Remove the duplicate so `-K`/`--concatenated` appears exactly once.","Make any wrapper that injects `-K` conditional: only add it when not already present in argv.","Run `brotli --help` to confirm the flag's canonical spelling before reconstructing the command."],"exampleFix":"# before\nbrotli -d -K -K in.br\n# after\nbrotli -d -K in.br","handlingStrategy":"validation","validationCode":"# bash: ensure -K / --concatenated appears at most once\nocc=$(printf '%s\\n' \"$@\" | grep -cE '^(-K|--concatenated)$')\nif [ \"$occ\" -gt 1 ]; then echo \"duplicate -K/--concatenated\" >&2; exit 2; fi\nbrotli \"$@\"","typeGuard":null,"tryCatchPattern":"# bash: detect brotli arg-validation failure\nif ! brotli \"$@\"; then\n  rc=$?\n  echo \"brotli failed (exit $rc); check stderr for the flag message\" >&2\n  exit \"$rc\"\nfi","preventionTips":["Build argv from a single source of truth rather than concatenating multiple flag lists.","Deduplicate known-exclusive flags before invoking brotli.","Print the final argv in debug mode so duplicates are visible."],"tags":["cli","brotli","argument-parsing","duplicate-flag"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}