{"record":{"id":"bf2266ac3dc1e266","repo":"apache/pulsar","slug":"invalid-message-config-key","errorCode":null,"errorMessage":"Invalid message config key '","messagePattern":"Invalid message config key '","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"pulsar-client/src/main/java/org/apache/pulsar/client/impl/TypedMessageBuilderImpl.java","lineNumber":270,"sourceCode":"                    this.sequenceId(checkType(value, Long.class));\n                    break;\n                case CONF_REPLICATION_CLUSTERS:\n                    this.replicationClusters(checkType(value, List.class));\n                    break;\n                case CONF_DISABLE_REPLICATION:\n                    boolean disableReplication = checkType(value, Boolean.class);\n                    if (disableReplication) {\n                        this.disableReplication();\n                    }\n                    break;\n                case CONF_DELIVERY_AFTER_SECONDS:\n                    this.deliverAfter(checkType(value, Long.class), TimeUnit.SECONDS);\n                    break;\n                case CONF_DELIVERY_AT:\n                    this.deliverAt(checkType(value, Long.class));\n                    break;\n                default:\n                    throw new RuntimeException(\"Invalid message config key '\" + key + \"'\");\n            }\n        });\n        return this;\n    }\n\n    public MessageMetadata getMetadataBuilder() {\n        return msgMetadata;\n    }\n\n    public Message<T> getMessage() {\n        beforeSend();\n        return MessageImpl.create(msgMetadata, content, schema, getTopic());\n    }\n\n    public long getPublishTime() {\n        return msgMetadata.getPublishTime();\n    }\n","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client/src/main/java/org/apache/pulsar/client/impl/TypedMessageBuilderImpl.java#L252-L288","documentation":"TypedMessageBuilderImpl.loadConf(Map) applies known message config keys via a switch; any key not matching a CONF_* constant hits the default branch and throws RuntimeException(\"Invalid message config key '\" + key + \"'\"). loadConf only supports a fixed set of message property names, so a typo or an unsupported key is a hard error.","triggerScenarios":"Passing a Map to TypedMessageBuilder.loadConf() containing any key not in the supported set (key, properties, eventTime, sequenceId, replicationClusters, disableReplication, deliverAt, deliverAfter, value, etc.), e.g. a misspelled 'deliverAtTime' instead of 'deliverAt'.","commonSituations":"Reusing producer-level config keys in message conf; typos after refactoring from deprecated keys; building conf maps from external config files where keys are not validated; copy-pasting keys between loadConf on Producer and on TypedMessageBuilder which accept different key sets.","solutions":["Fix the key name to one of the supported TypedMessageBuilder config keys (e.g. 'deliverAt', 'deliverAfter', 'eventTime', 'sequenceId', 'properties').","Replace loadConf with direct builder calls (typedMessageBuilder.deliverAt(...), .properties(...)) so the compiler catches mistakes.","Validate incoming conf map keys against the supported whitelist before calling loadConf."],"exampleFix":"// before\nbuilder.loadConf(Map.of(\"deliverAtTime\", System.currentTimeMillis() + 5000));\n// after\nbuilder.loadConf(Map.of(\"deliverAt\", System.currentTimeMillis() + 5000));","handlingStrategy":"validation","validationCode":"Set<String> ALLOWED = Set.of(\"key\", \"properties\", \"eventTime\", \"sequenceId\",\n    \"replicationClusters\", \"disableReplication\", \"deliverAt\", \"deliverAfter\", \"value\");\nconf.keySet().forEach(k -> {\n    if (!ALLOWED.contains(k)) throw new IllegalArgumentException(\"Unsupported message config key: \" + k);\n});","typeGuard":null,"tryCatchPattern":"try {\n    builder.loadConf(conf);\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"Invalid message config key\")) {\n        log.error(\"bad message conf key: {}\", e.getMessage());\n    } else throw e;\n}","preventionTips":["Prefer direct TypedMessageBuilder setter methods over loadConf so typos fail at compile time.","Keep a whitelist constant of supported message config keys and validate maps against it.","Check key names against the producer's CONF_* constants when copy-pasting configs."],"tags":["java","configuration","message-metadata","pulsar-client"],"backgroundTag":"invalid-config-key","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}