{"record":{"id":"7db9b48064721c62","repo":"apache/pulsar","slug":"default-config-can-t-be-modified","errorCode":null,"errorMessage":"'${DEFAULT_CONFIG}' can't be modified.","messagePattern":"'(.+?)' can't be modified\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/shell/config/FileConfigStore.java","lineNumber":88,"sourceCode":"        try (final BufferedInputStream buffered = new BufferedInputStream(new FileInputStream(file));) {\n            try {\n                fileConfig = mapper.readValue(buffered, FileConfig.class);\n            } catch (MismatchedInputException mismatchedInputException) {\n                fileConfig = new FileConfig();\n            }\n        }\n    }\n\n    private void write() throws IOException {\n        try (final BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(file));) {\n            mapper.writeValue(bufferedOutputStream, fileConfig);\n        }\n    }\n\n    @Override\n    public void putConfig(ConfigEntry entry) throws IOException {\n        if (DEFAULT_CONFIG.equals(entry.getName())) {\n            throw new IllegalArgumentException(\"'\" + DEFAULT_CONFIG + \"' can't be modified.\");\n        }\n        ConfigStore.cleanupValue(entry);\n        fileConfig.configs.put(entry.getName(), entry);\n        write();\n    }\n\n    @Override\n    public ConfigEntry getConfig(String name) {\n        if (DEFAULT_CONFIG.equals(name)) {\n            return defaultConfig;\n        }\n        return fileConfig.configs.get(name);\n    }\n\n    @Override\n    public void deleteConfig(String name) throws IOException{\n        if (DEFAULT_CONFIG.equals(name)) {\n            throw new IllegalArgumentException(\"'\" + DEFAULT_CONFIG + \"' can't be deleted.\");","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/shell/config/FileConfigStore.java#L70-L106","documentation":"FileConfigStore (the pulsar-shell local config store) reserves the name DEFAULT_CONFIG for built-in defaults. putConfig rejects any ConfigEntry with that name, throwing IllegalArgumentException, so the reserved profile cannot be overwritten; create/use a named profile instead.","triggerScenarios":"Calling putConfig() with entry.getName() equal to DEFAULT_CONFIG, or via `pulsar-shell --set-config default ...` style commands targeting the reserved profile name.","commonSituations":"Users trying to edit the implicit 'default' configuration shown by config list; scripts that write settings back under a name read from defaults; tooling that round-trips all config entries including the default one.","solutions":["Save settings under a named profile, e.g. putConfig with name 'myprofile', then reference that profile at startup.","Do not attempt to modify the default profile; copy its values into a new named entry and change that.","Adjust scripts that iterate configs to skip the reserved default entry when writing back."],"exampleFix":"// before\nstore.putConfig(new ConfigEntry(\"default\", \"http://localhost:8080\"));\n// after\nstore.putConfig(new ConfigEntry(\"myprofile\", \"http://localhost:8080\"));","handlingStrategy":"validation","validationCode":"// Java\nif (\"default\".equalsIgnoreCase(entry.getName())) { throw new IllegalArgumentException(\"use a named profile, not the default config\"); }\nstore.putConfig(entry);","typeGuard":"function isWritableProfile(name) { return typeof name === 'string' && name.length > 0 && name !== 'default'; }","tryCatchPattern":"try { store.putConfig(entry); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"can't be modified\")) { entry = new ConfigEntry(\"myprofile\", entry.getValue()); store.putConfig(entry); } else throw e; }","preventionTips":["Treat the default config as read-only; always write named profiles.","Skip the default entry when round-tripping stored configs.","Keep the profile name in one place in scripts so writes go to your own profile."],"tags":["cli","shell","config","validation"],"backgroundTag":"reserved-config-name","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"}