{"record":{"id":"43ddaeaf2dbc4b68","repo":"apache/hadoop","slug":"invalid-vecsum-type-environment-variable-valid-v","errorCode":null,"errorMessage":"Invalid VECSUM_TYPE environment variable.  Valid values are libhdfs, zcr, or local\n","messagePattern":"Invalid VECSUM_TYPE environment variable\\.  Valid values are libhdfs, zcr, or local\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/vecsum.c","lineNumber":217,"sourceCode":"            \"variable to the number of passes to make.\\n\");\n        goto error;\n    }\n    opts->passes = atoi(pass_str);\n    if (opts->passes <= 0) {\n        fprintf(stderr, \"Invalid value for the VECSUM_PASSES \"\n            \"environment variable.  You must set this to a \"\n            \"number greater than 0.\\n\");\n        goto error;\n    }\n    ty_str = getenv(\"VECSUM_TYPE\");\n    if (!ty_str) {\n        fprintf(stderr, \"You must set the VECSUM_TYPE environment \"\n            \"variable to \" VECSUM_TYPE_VALID_VALUES \"\\n\");\n        goto error;\n    }\n    ty = parse_vecsum_type(ty_str);\n    if (ty < 0) {\n        fprintf(stderr, \"Invalid VECSUM_TYPE environment variable.  \"\n            \"Valid values are \" VECSUM_TYPE_VALID_VALUES \"\\n\");\n        goto error;\n    }\n    opts->ty = ty;\n    opts->rpc_address = getenv(\"VECSUM_RPC_ADDRESS\");\n    if (!opts->rpc_address) {\n        opts->rpc_address = \"default\";\n    }\n    return opts;\nerror:\n    free(opts);\n    return NULL;\n}\n\nstatic int test_file_chunk_setup(double **chunk)\n{\n    int i;\n    double *c, val;","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/vecsum.c#L199-L235","documentation":"vecsum read its VECSUM_TYPE setting but parse_vecsum_type() (vecsum.c:132) did not recognize the token, returning -1. Only the exact words local, libhdfs, and zcr are accepted, matched case-insensitively via strcasecmp. Any other spelling, extra whitespace, quoting artifact, or trailing newline makes the run abort at startup.","triggerScenarios":"Exporting VECSUM_TYPE with a value outside {local, libhdfs, zcr}, e.g. VECSUM_TYPE=LOCAL works (strcasecmp) but VECSUM_TYPE=\"libhdfs \" , VECSUM_TYPE=hdfs, VECSUM_TYPE=zcr\\n (from a file read without chomp) or VECSUM_TYPE=LIBHDFS_V2 all fail parse_vecsum_type and hit the ty < 0 branch at vecsum.c:216.","commonSituations":"Scripts that generate VECSUM_TYPE dynamically and append whitespace or a newline; renaming a backend in a newer Hadoop version and running with the old name; typos like 'libhdfs' vs 'libhdfsplus'; values sourced from a config file with CRLF line endings.","solutions":["Use exactly one of the three tokens: export VECSUM_TYPE=libhdfs (case does not matter, spelling does).","Print the value with delimiters to expose invisible characters: printf '[%s]\\n' \"$VECSUM_TYPE\" — look for trailing spaces, CR, or newline.","If the value comes from a file or pipeline, strip whitespace: export VECSUM_TYPE=$(tr -d '[:space:]\\r\\n' < /tmp/ty.txt).","Check you are not running a different/older vecsum build whose accepted values differ from the ones in its own usage message."],"exampleFix":"# before\nexport VECSUM_TYPE=\"libhdfs \"   # trailing space → parse_vecsum_type returns -1\n./vecsum\n\n# after\nexport VECSUM_TYPE=$(printf '%s' \"libhdfs \" | tr -d '[:space:]')\n./vecsum","handlingStrategy":"validation","validationCode":"# reject values vecsum's strcasecmp match will refuse\nty=$(printf '%s' \"${VECSUM_TYPE:-}\" | tr -d '[:space:]\\r\\n')\ncase \"$ty\" in\n  local|LOCAL|libhdfs|LIBHDFS|zcr|ZCR|lOcAl|LiBhDfS|ZcR) export VECSUM_TYPE=\"$ty\" ;;\n  *) printf 'bad VECSUM_TYPE [%s] — use libhdfs, zcr, or local\\n' \"$ty\" >&2; exit 2 ;;\nesac","typeGuard":"/* if you embed vecsum's option parsing, use an enum + validator */\nenum vecsum_type { VECSUM_LOCAL = 0, VECSUM_LIBHDFS, VECSUM_ZCR };\nstatic int valid_vecsum_type(const char *s) {\n    return strcasecmp(s, \"local\") == 0 ||\n           strcasecmp(s, \"libhdfs\") == 0 ||\n           strcasecmp(s, \"zcr\") == 0;\n}","tryCatchPattern":null,"preventionTips":["Generate VECSUM_TYPE from a whitelist in scripts, never from free-form input.","Strip whitespace/CR/LF from values read from files: tr -d '[:space:]\\r\\n'.","On upgrades, re-check the valid list in the binary's own error message — it is the source of truth."],"tags":["environment-variable","configuration","input-validation","vecsum"],"backgroundTag":"invalid-env-var-value","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}