{"record":{"id":"15371dcccd3a89c1","repo":"apache/pulsar","slug":"malformed-configuration-file","errorCode":null,"errorMessage":"Malformed configuration file","messagePattern":"Malformed configuration file","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/PulsarBrokerStarter.java","lineNumber":120,"sourceCode":"        @Option(names = {\"-h\", \"--help\"}, usageHelp = true, description = \"Show this help message\")\n        private boolean help = false;\n\n        @Option(names = {\"-g\", \"--generate-docs\"}, description = \"Generate docs\")\n        private boolean generateDocs = false;\n    }\n\n    private static ServerConfiguration readBookieConfFile(String bookieConfigFile) throws IllegalArgumentException {\n        ServerConfiguration bookieConf = new ServerConfiguration();\n        try {\n            bookieConf.loadConf(new File(bookieConfigFile).toURI().toURL());\n            bookieConf.validate();\n            log.info().attr(\"file\", bookieConfigFile).log(\"Using bookie configuration file\");\n        } catch (MalformedURLException e) {\n            log.error().attr(\"file\", bookieConfigFile).exception(e).log(\"Could not open configuration file\");\n            throw new IllegalArgumentException(\"Could not open configuration file\");\n        } catch (ConfigurationException e) {\n            log.error().attr(\"file\", bookieConfigFile).exception(e).log(\"Malformed configuration file\");\n            throw new IllegalArgumentException(\"Malformed configuration file\");\n        }\n\n        if (bookieConf.getMaxPendingReadRequestPerThread() < bookieConf.getRereplicationEntryBatchSize()) {\n            throw new IllegalArgumentException(\n                \"rereplicationEntryBatchSize should be smaller than \" + \"maxPendingReadRequestPerThread\");\n        }\n        return bookieConf;\n    }\n\n    protected static class BrokerStarter implements Callable<Integer> {\n        private ServiceConfiguration brokerConfig;\n        private PulsarService pulsarService;\n        private LifecycleComponent bookieServer;\n        private volatile CompletableFuture<Void> bookieStartFuture;\n        private AutoRecoveryMain autoRecoveryMain;\n        private StatsProvider bookieStatsProvider;\n        private ServerConfiguration bookieConfig;\n        private WorkerService functionsWorkerService;","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/PulsarBrokerStarter.java#L102-L138","documentation":"readBookieConfFile catches ConfigurationException from bookieConf.loadConf/bookieConf.validate and rethrows it as 'Malformed configuration file'. It means the Bookie configuration file exists but cannot be parsed or fails validation by the configuration framework.","triggerScenarios":"Bookie config file contains invalid syntax, wrong value types (e.g. non-numeric port), or a value that fails BookKeeper's Configuration validate() step; thrown when --bookie-config points to a parseable-path but invalid-content file.","commonSituations":"Hand-edited bookie.conf with typos; copying an incompatible bookkeeper config across versions; missing required properties; wrong encoding or stray characters in the file.","solutions":["Fix the syntax/values in the bookie configuration file; compare against conf/bookie.conf shipped with your Pulsar version","Check the logged ConfigurationException (stack trace shows the offending property)","Validate types of numeric/boolean properties and remove unsupported keys from old versions"],"exampleFix":"// before (bookie.conf)\nbookiePort=not-a-number\n// after\nbookiePort=3181","handlingStrategy":"validation","validationCode":"// Pre-parse check in the caller\nProperties props = new Properties();\ntry (InputStream in = Files.newInputStream(Path.of(bookieConfigFile))) {\n    props.load(in);\n    if (!props.stringPropertyNames().contains(\"bookiePort\")) {\n        throw new IllegalStateException(\"bookie.conf missing required keys\");\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    BookKeeperConfiguration conf = readBookieConfFile(bookieConfigFile);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"Malformed configuration file\")) {\n        throw new IllegalStateException(\"Invalid bookie.conf \" + bookieConfigFile + \": fix syntax/types\", e);\n    }\n    throw e;\n}","preventionTips":["Keep bookie.conf generated from the shipped template for your Pulsar version","Validate config files in CI before deployment","Diff hand edits against the pristine conf to spot bad keys/types"],"tags":["configuration","startup","parsing"],"backgroundTag":"malformed-config-file","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"}