{"record":{"id":"c96dbbcd7f8f1313","repo":"redis/jedis","slug":"must-not-contain-spaces-newlines-non-printable","errorCode":null,"errorMessage":" must not contain spaces, newlines, non-printable characters, or braces","messagePattern":" must not contain spaces, newlines, non-printable characters, or braces","errorType":"validation","errorClass":"JedisValidationException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/DriverInfo.java","lineNumber":244,"sourceCode":"\n    validateNoInvalidCharacters(value, fieldName);\n  }\n\n  /**\n   * Validates that the value does not contain characters that would violate the format of the Redis\n   * CLIENT LIST reply: non-printable characters, spaces, or brace characters.\n   * <p>\n   * Only printable ASCII characters (0x21-0x7E, i.e., '!' to '~') are allowed, excluding braces.\n   * @param value the value to validate\n   * @param fieldName the name of the field for error messages\n   * @throws JedisValidationException if the value contains invalid characters\n   * @see <a href=\"https://redis.io/docs/latest/commands/client-setinfo/\">CLIENT SETINFO</a>\n   */\n  private static void validateNoInvalidCharacters(String value, String fieldName) {\n    for (int i = 0; i < value.length(); i++) {\n      char c = value.charAt(i);\n      if (c < '!' || c > '~' || BRACES.contains(c)) {\n        throw new JedisValidationException(\n            fieldName + \" must not contain spaces, newlines, non-printable characters, or braces\");\n      }\n    }\n  }\n\n  private static String formatDriverInfo(String driverName, String driverVersion) {\n    return driverName + \"_v\" + driverVersion;\n  }\n}\n","sourceCodeStart":226,"sourceCodeEnd":254,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/DriverInfo.java#L226-L254","documentation":"DriverInfo.validateNoInvalidCharacters throws JedisValidationException when a driver name or version contains any character outside printable ASCII '!'..'~' or contains braces ({ or }). Spaces, newlines, tabs, control characters, and non-ASCII characters are all rejected because CLIENT SETINFO lib entries must be single printable tokens.","triggerScenarios":"addUpstreamDriver(\"my driver\", \"1.0\") (space in name); addUpstreamDriver(\"driver\", \"1.0\\n\"); versions containing \"{\"/\"}\"; names with UTF-8 or emoji characters; values copied with trailing whitespace or BOM.","commonSituations":"Versions like \"1.0 (build 42)\" containing spaces/parens are fine but \"1.0 beta\" is not; branding names with curly braces or unicode; values read from Windows files with CRLF endings; templates injecting values with newlines.","solutions":["Sanitize the value: strip or replace spaces, newlines, and braces, e.g. value.replaceAll(\"[^!-~]|[{}],\", \"\")-style filtering keeping only printable non-brace ASCII.","Use a compact identifier such as \"my-driver\" and \"1.0.0-beta1\" instead of free-form text.","Validate caller-side with a regex like ^[!-~&&[^{}]]+$ before calling addUpstreamDriver."],"exampleFix":"// before\nbuilder.addUpstreamDriver(\"My Cool Driver\", version); // spaces rejected\n// after\nString safe = version == null ? \"unknown\" : version.replaceAll(\"[^\\\\x21-\\\\x7E]\", \"\").replace(\"{\", \"\").replace(\"}\", \"\");\nbuilder.addUpstreamDriver(\"MyCoolDriver\", safe);","handlingStrategy":"validation","validationCode":"static boolean isValidDriverField(String s) {\n  if (s == null) return false;\n  for (char c : s.toCharArray()) {\n    if (c < '!' || c > '~' || c == '{' || c == '}') return false;\n  }\n  return !s.isEmpty();\n}","typeGuard":null,"tryCatchPattern":"try {\n  builder.addUpstreamDriver(name, version);\n} catch (JedisValidationException e) {\n  log.warn(\"Driver field has invalid characters: {}\", e.getMessage());\n}","preventionTips":["Restrict driver names/versions to printable ASCII identifiers (letters, digits, dot, dash, underscore).","Sanitize values read from files/env to strip newlines, BOMs, and whitespace.","Never embed braces or spaces in version strings; use semver-like tokens."],"tags":["validation","invalid-characters","driver-info"],"backgroundTag":"invalid-argument-format","analyzedSha":"6dac31d4c224fb3257c216f3985340c6f500cdcb","analyzedAt":"2026-09-08T04:55:01.204Z","contentChangedAt":"2026-09-08T04:55:01.204Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}