{"record":{"id":"6809f4fe4e2e6341","repo":"apache/hadoop","slug":"invalid-value","errorCode":null,"errorMessage":"Invalid value","messagePattern":"Invalid value","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/wsrs/StringParam.java","lineNumber":60,"sourceCode":"      if (str != null) {\n        str = str.trim();\n        if (str.length() > 0) {\n          value = parse(str);\n        }\n      }\n    } catch (Exception ex) {\n      throw new IllegalArgumentException(\n        MessageFormat.format(\"Parameter [{0}], invalid value [{1}], value must be [{2}]\",\n                             getName(), str, getDomain()));\n    }\n    return value;\n  }\n\n  @Override\n  protected String parse(String str) throws Exception {\n    if (pattern != null) {\n      if (!pattern.matcher(str).matches()) {\n        throw new IllegalArgumentException(\"Invalid value\");\n      }\n    }\n    return str;\n  }\n\n  @Override\n  protected String getDomain() {\n    return (pattern == null) ? \"a string\" : pattern.pattern();\n  }\n}\n","sourceCodeStart":42,"sourceCodeEnd":71,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/wsrs/StringParam.java#L42-L71","documentation":"StringParam.parse (StringParam.java:60) throws this bare IllegalArgumentException(\"Invalid value\") when the configured pattern does not match the string. It is an internal sentinel: the public entry point StringParam.parseParam catches every exception and rethrows the parameterized message (error 3690), so end users should never see this raw text — it appears only when parse() is invoked directly, e.g. by unit tests or subclasses reusing parse() internally.","triggerScenarios":"Direct invocation of a StringParam subclass's parse(\"bad-value\") — bypassing parseParam — in tests or custom code; any value that violates the subclass Pattern (e.g. an xattr name without namespace prefix) reaches this throw on the normal path but is immediately wrapped.","commonSituations":"Test code exercising parse() directly; custom frameworks calling the protected parse() for internal reuse and leaking the uninformative message into logs.","solutions":["Call parseParam(str), never parse(str), from application code — you get the wrapped message naming the parameter and the required regex.","Fix the value to satisfy the subclass pattern.","When subclassing StringParam, set a descriptive pattern since getDomain() surfaces it in client-visible errors."],"exampleFix":"// before\nnew XattrNameParam().parse(\"myattr\"); // throws bare 'Invalid value'\n\n// after\nnew XattrNameParam().parseParam(\"myattr\"); // 'Parameter [xattr.name], invalid value [myattr], value must be [..regex..]'","handlingStrategy":"validation","validationCode":"String name = params.get(\"xattr.name\");\nif (name != null && !Pattern.matches(\"(user|trusted|security|system)\\\\..+\", name)) {\n  // do not send: value would fail the server-side pattern\n  return badRequest(\"xattr.name must be namespace.name\");\n}","typeGuard":"static boolean matchesDomain(String v, Pattern p) {\n  return v == null || p.matcher(v).matches();\n}","tryCatchPattern":"// Do not call the protected parse() directly; parseParam wraps this sentinel\n// into a message naming the parameter and the required regex:\ntry { param.parseParam(str); } catch (IllegalArgumentException ex) { return badRequest(ex.getMessage()); }","preventionTips":["Never call the protected parse() from application code.","Treat a bare 'Invalid value' in logs as a smell: something bypassed parseParam.","Keep the subclass pattern descriptive — it becomes the user-visible domain."],"tags":["java","hadoop","httpfs","validation","regex"],"backgroundTag":"regex-pattern-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}