{"record":{"id":"3f0ae6f263294b7e","repo":"redis/jedis","slug":"driver-name-must-not-be-null","errorCode":null,"errorMessage":"Driver name must not be null","messagePattern":"Driver name must not be null","errorType":"validation","errorClass":"JedisValidationException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/DriverInfo.java","lineNumber":181,"sourceCode":"     * hyphens, and underscores only, starting with a lowercase letter. Dots are only allowed after\n     * digits (for Scala cross-version naming like akka-redis_2.13).\n     * <p>\n     * Both values must not contain spaces, newlines, non-printable characters, or brace characters\n     * as these would violate the format of the Redis CLIENT LIST reply.\n     * @param driverName the name of the upstream driver (e.g., \"spring-data-redis\"), must not be\n     *          {@code null}\n     * @param driverVersion the version of the upstream driver (e.g., \"3.2.0\"), must not be\n     *          {@code null}\n     * @return this builder\n     * @throws JedisValidationException if the driver name or version is {@code null} or has invalid\n     *           format\n     * @see <a href=\"https://maven.apache.org/guides/mini/guide-naming-conventions.html\">Maven\n     *      Naming Conventions</a>\n     * @see <a href=\"https://redis.io/docs/latest/commands/client-setinfo/\">CLIENT SETINFO</a>\n     */\n    public Builder addUpstreamDriver(String driverName, String driverVersion) {\n      if (driverName == null) {\n        throw new JedisValidationException(\"Driver name must not be null\");\n      }\n      if (driverVersion == null) {\n        throw new JedisValidationException(\"Driver version must not be null\");\n      }\n      validateDriverField(driverName, \"Driver name\");\n      validateDriverField(driverVersion, \"Driver version\");\n      String formattedDriverInfo = formatDriverInfo(driverName, driverVersion);\n      this.upstreamDrivers.add(0, formattedDriverInfo);\n      return this;\n    }\n\n    public Builder addUpstreamDriver(String driverName) {\n      if (driverName == null) {\n        throw new JedisValidationException(\"Driver name must not be null\");\n      }\n      validateDriverField(driverName, \"Driver name\");\n      this.upstreamDrivers.add(0, driverName);\n      return this;","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/DriverInfo.java#L163-L199","documentation":"DriverInfo.Builder.addUpstreamDriver(String driverName, String driverVersion) registers an upstream driver for CLIENT SETINFO reporting and rejects a null driverName with JedisValidationException('Driver name must not be null'). Non-null values are further checked by validateDriverField (format/naming rules), so both name and version must be valid, non-empty, well-formed strings.","triggerScenarios":"Calling addUpstreamDriver(null, ...) with a driver name obtained from a null-returning lookup (package metadata, DI bean, config); a null check on driverVersion similarly throws 'Driver version must not be null'; values that are non-null but malformed fail validateDriverField.","commonSituations":"Middleware/frameworks (e.g. Spring Data Redis wrappers) registering the underlying driver and passing through an unresolved metadata field; dynamic discovery of driver version from a manifest that is absent; copy-paste where arguments are swapped or one is left null.","solutions":["Pass non-null, non-empty literals or resolved values for both driverName and driverVersion, e.g. addUpstreamDriver(\"lettuce-core\", \"6.3.0\").","Default null lookups before the call: use a fallback name/version when metadata is unavailable.","Check the metadata source (manifest, package info, config) that should supply the driver name/version.","Validate upstream values at the caller's boundary with Objects.requireNonNull to get a clearer stack trace.","Review validateDriverField rules and ensure the values satisfy the naming conventions before calling."],"exampleFix":"// before\nString driver = detectDriver(); // may return null\ninfo.addUpstreamDriver(driver, version);\n\n// after\nString driver = detectDriver();\nif (driver != null) {\n  info.addUpstreamDriver(driver, version != null ? version : \"unknown\");\n}","handlingStrategy":"validation","validationCode":"if (driverName != null && driverVersion != null) {\n  driverBuilder.addUpstreamDriver(driverName, driverVersion);\n}","typeGuard":"static boolean isValidDriverPair(String name, String version) {\n  return name != null && version != null;\n}","tryCatchPattern":"try {\n  driverBuilder.addUpstreamDriver(name, version);\n} catch (JedisValidationException e) {\n  // skip upstream-driver registration or use non-null defaults\n  driverBuilder.addUpstreamDriver(name != null ? name : \"unknown\", version != null ? version : \"unknown\");\n}","preventionTips":["Check both driverName and driverVersion for null before calling addUpstreamDriver; each has its own null guard.","Provide fallback values (e.g. \"unknown\") for driver metadata discovered dynamically from manifests or config.","Keep argument order (name, version) in mind — swapped arguments can trip the format validation in validateDriverField.","Centralize upstream-driver registration in one helper that performs the null checks once.","Cover the metadata-discovery path with tests simulating missing metadata."],"tags":["validation","null","driver-info","client-setinfo"],"backgroundTag":"null-argument","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"}