{"record":{"id":"a7e7b0947c0d9637","repo":"nodejs/node","slug":"quality-already-set-n","errorCode":null,"errorMessage":"quality already set\\n","messagePattern":"quality already set\\\\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/brotli/c/tools/brotli.c","lineNumber":424,"sourceCode":"            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 */\n        if (c != 'o' && c != 'q' && c != 'w' && c != 'C' && c != 'D' &&\n            c != 'S') {\n          fprintf(stderr, \"invalid argument -%c\\n\", c);\n          return COMMAND_INVALID;\n        }\n        if (j + 1 != arg_len) {\n          fprintf(stderr, \"expected parameter for argument -%c\\n\", c);\n          return COMMAND_INVALID;\n        }\n        i++;\n        if (i == argc || !argv[i] || argv[i][0] == 0) {","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/brotli/c/tools/brotli.c#L406-L442","documentation":"`-Z` is a shortcut that pins compression quality to 11 (the maximum). The parser latches quality via `quality_set`, shared with `-q`, `--best`, and another `-Z`. Supplying `-Z` after any quality-affecting option triggers this message and returns COMMAND_INVALID.","triggerScenarios":"Passing `-Z` together with another quality setter: `brotli -Z -q 9 f`, `brotli --best -Z f`, or `brotli -Z -Z f`.","commonSituations":"Preset wrappers that always add `-Z` while a user also passes `-q`; migrating from `gzip -9` habits and adding both `-Z` and an explicit quality.","solutions":["Drop one quality setter: keep either `-Z`/`--best`/`-q 11` or an explicit `-q N`, not several.","Audit build scripts that hard-code a quality flag and parameterize it instead."],"exampleFix":"# before\nbrotli -Z -q 9 in.txt\n# after\nbrotli -q 11 in.txt","handlingStrategy":"validation","validationCode":"# bash: count quality setters (-Z, --best, -q, --quality)\nq=$(printf '%s\\n' \"$@\" | grep -cE '^(-Z|--best|-q|--quality.*)$')\nif [ \"$q\" -gt 1 ]; then echo \"multiple quality flags\" >&2; exit 2; fi\nbrotli \"$@\"","typeGuard":null,"tryCatchPattern":"# bash\nif ! brotli \"$@\"; then rc=$?; echo \"brotli exit $rc\" >&2; exit \"$rc\"; fi","preventionTips":["Centralize the quality value in one variable and emit a single flag.","Prefer `-q \"$Q\"` over mixing `-Z`/`--best` with explicit numbers."],"tags":["cli","brotli","argument-parsing","duplicate-flag","quality"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}