{"record":{"id":"cb73de40736475ad","repo":"apache/pulsar","slug":"rack-name-is-invalid-it-should-not-be-null-empty","errorCode":null,"errorMessage":"rack name is invalid, it should not be null, empty or '/'","messagePattern":"rack name is invalid, it should not be null, empty or '/'","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-client-admin-api/src/main/java/org/apache/pulsar/common/policies/data/impl/BookieInfoImpl.java","lineNumber":64,"sourceCode":"        public BookieInfoImplBuilder rack(String rack) {\n            this.rack = rack;\n            return this;\n        }\n\n        public BookieInfoImplBuilder hostname(String hostname) {\n            this.hostname = hostname;\n            return this;\n        }\n\n        public BookieInfoImpl build() {\n            checkArgument(rack != null && !rack.isEmpty() && !rack.equals(PATH_SEPARATOR),\n                    \"rack name is invalid, it should not be null, empty or '/'\");\n            return new BookieInfoImpl(rack, hostname);\n        }\n\n        public static void checkArgument(boolean expression, @NonNull Object errorMessage) {\n            if (!expression) {\n                throw new IllegalArgumentException(String.valueOf(errorMessage));\n            }\n        }\n    }\n}\n","sourceCodeStart":46,"sourceCodeEnd":69,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-admin-api/src/main/java/org/apache/pulsar/common/policies/data/impl/BookieInfoImpl.java#L46-L69","documentation":"BookieInfoImpl.Builder.checkArgument throws IllegalArgumentException when the rack name is null, empty, or '/'. Bookie rack names used for placement awareness must be a non-empty string identifying a rack, and '/' is rejected as invalid.","triggerScenarios":"Calling bookieInfo build()/setBookieInfo with rack = null, \"\", or \"/\" — e.g. parsing a rack string from an environment variable or config file that is unset or contains just a slash.","commonSituations":"Empty RACK env/config in deployment scripts, yaml config with rack: / placeholder, script defaulting rack to '/' thinking it means root, or hostname/rack splitting logic producing empty strings.","solutions":["Provide a concrete rack name like \"/dc1/rack0\" path-style identifier (non-empty, not just \"/\") per your placement policy","Validate the rack string before building: rack != null && !rack.isEmpty() && !rack.equals(\"/\")","Fix the source config/env var that supplies the rack value"],"exampleFix":"// before\nString rack = System.getenv(\"BOOKIE_RACK\"); // may be \"/\" or empty\nBookieInfoImpl info = BookieInfoImpl.builder().rack(rack).hostname(host).build();\n// after\nString rack = System.getenv(\"BOOKIE_RACK\");\nif (rack == null || rack.isEmpty() || \"/\".equals(rack)) {\n    rack = \"/default-rack\";\n}\nBookieInfoImpl info = BookieInfoImpl.builder().rack(rack).hostname(host).build();","handlingStrategy":"validation","validationCode":"boolean isValidRack(String rack) {\n    return rack != null && !rack.isEmpty() && !\"/\".equals(rack);\n}","typeGuard":null,"tryCatchPattern":"try {\n    BookieInfoImpl info = BookieInfoImpl.builder().rack(rack).hostname(host).build();\n} catch (IllegalArgumentException e) {\n    logger.error(\"Invalid rack '{}': must be non-null, non-empty, and not '/'\", rack);\n}","preventionTips":["Fail fast on empty/placeholder rack env vars at deployment","Use full rack paths like /dc/rackN","Validate config files that carry rack names before rollout"],"tags":["validation","illegal-argument","configuration","rack"],"backgroundTag":"invalid-configuration-value","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}