{"record":{"id":"7353309ebb3481da","repo":"nodejs/node","slug":"command-already-set-when-parsing-test-n","errorCode":null,"errorMessage":"command already set when parsing --test\\n","messagePattern":"command already set when parsing --test\\\\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/brotli/c/tools/brotli.c","lineNumber":577,"sourceCode":"        params->junk_source = BROTLI_TRUE;\n      } else if (strcmp(\"squash\", arg) == 0) {\n        if (squash_set) {\n          fprintf(stderr, \"argument --squash / -s already set\\n\");\n          return COMMAND_INVALID;\n        }\n        squash_set = BROTLI_TRUE;\n        params->reject_uncompressible = BROTLI_TRUE;\n        continue;\n      } else if (strcmp(\"stdout\", arg) == 0) {\n        if (output_set) {\n          fprintf(stderr, \"write to standard output already set\\n\");\n          return COMMAND_INVALID;\n        }\n        output_set = BROTLI_TRUE;\n        params->write_to_stdout = BROTLI_TRUE;\n      } else if (strcmp(\"test\", arg) == 0) {\n        if (command_set) {\n          fprintf(stderr, \"command already set when parsing --test\\n\");\n          return COMMAND_INVALID;\n        }\n        command_set = BROTLI_TRUE;\n        command = COMMAND_TEST_INTEGRITY;\n      } else if (strcmp(\"verbose\", arg) == 0) {\n        if (params->verbosity > 0) {\n          fprintf(stderr, \"argument --verbose / -v already set\\n\");\n          return COMMAND_INVALID;\n        }\n        params->verbosity = 1;\n      } else if (strcmp(\"version\", arg) == 0) {\n        /* Don't parse further. */\n        return COMMAND_VERSION;\n      } else {\n        /* key=value */\n        const char* value = strchr(arg, '=');\n        size_t key_len;\n        if (!value || value[1] == 0) {","sourceCodeStart":559,"sourceCodeEnd":595,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/brotli/c/tools/brotli.c#L559-L595","documentation":"The brotli CLI allows exactly one operation per invocation: compress (default), `--decompress`/`-d`, or `--test`/`-t`. The parser tracks this with `command_set`; encountering `--test` after any prior command returns COMMAND_INVALID rather than silently shadowing the earlier one.","triggerScenarios":"Invoking `brotli --decompress --test file.br`, `brotli -z --test file`, or `brotli --test --test file.br`; aliasing brotli with `-d` and then adding `--test`.","commonSituations":"CI jobs that combine a verification step (`--test`) with a decompression step in one command; users coming from `gzip -t` expecting to chain modes; copy-paste concatenation of two how-to snippets.","solutions":["Split into two invocations: one to decompress, a separate `brotli --test` for integrity checking.","If only verifying integrity, remove the prior command flag (`--decompress`/`-z`).","If only decompressing, remove `--test`."],"exampleFix":"# before\nbrotli -d --test archive.br\n# after (two steps)\nbrotli -d archive.br -o archive\nbrotli --test archive.br","handlingStrategy":"validation","validationCode":"# Allow at most one command-mode flag.\ncmds=0\nfor a in \"$@\"; do\n  case \"$a\" in\n    --decompress|-d|--test|-t|-z) cmds=$((cmds+1));;\n  esac\ndone\n[ \"$cmds\" -gt 1 ] && { echo 'multiple command modes' >&2; exit 2; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run integrity checks (`--test`) as a separate invocation from compression/decompression.","Do not concatenate how-to snippets without reviewing flag conflicts.","Remember brotli defaults to compress when no mode flag is given."],"tags":["brotli","cli","argument-parsing","mutually-exclusive-flags","command-mode"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}