{"record":{"id":"094237caa13c8c0b","repo":"apache/rocketmq","slug":"invalid-consumefromwhere-value","errorCode":null,"errorMessage":"Invalid ConsumeFromWhere Value","messagePattern":"Invalid ConsumeFromWhere Value","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/org/apache/rocketmq/client/consumer/DefaultLitePullConsumer.java","lineNumber":579,"sourceCode":"    }\n\n    public void setTopicMetadataCheckIntervalMillis(long topicMetadataCheckIntervalMillis) {\n        this.topicMetadataCheckIntervalMillis = topicMetadataCheckIntervalMillis;\n    }\n\n    public void setConsumerGroup(String consumerGroup) {\n        this.consumerGroup = consumerGroup;\n    }\n\n    public ConsumeFromWhere getConsumeFromWhere() {\n        return consumeFromWhere;\n    }\n\n    public void setConsumeFromWhere(ConsumeFromWhere consumeFromWhere) {\n        if (consumeFromWhere != ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET\n            && consumeFromWhere != ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET\n            && consumeFromWhere != ConsumeFromWhere.CONSUME_FROM_TIMESTAMP) {\n            throw new RuntimeException(\"Invalid ConsumeFromWhere Value\", null);\n        }\n        this.consumeFromWhere = consumeFromWhere;\n    }\n\n    public String getConsumeTimestamp() {\n        return consumeTimestamp;\n    }\n\n    public void setConsumeTimestamp(String consumeTimestamp) {\n        this.consumeTimestamp = consumeTimestamp;\n    }\n\n    public TraceDispatcher getTraceDispatcher() {\n        return traceDispatcher;\n    }\n\n    private void setTraceDispatcher() {\n        if (enableTrace) {","sourceCodeStart":561,"sourceCodeEnd":597,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultLitePullConsumer.java#L561-L597","documentation":"DefaultLitePullConsumer.setConsumeFromWhere only accepts CONSUME_FROM_FIRST_OFFSET, CONSUME_FROM_LAST_OFFSET, or CONSUME_FROM_TIMESTAMP; any other value (including null or a locally-added enum constant) throws a bare RuntimeException. Note this lite consumer does NOT support CONSUME_FROM_FIRST_OFFSET semantics for brand-new groups the same way the push consumer does, but the setter's whitelist is the three listed constants. It is a fail-fast guard against unsupported start positions.","triggerScenarios":"Calling defaultLitePullConsumer.setConsumeFromWhere(null), or with a value obtained from untyped config/serialization that decodes to null or an unknown enum constant.","commonSituations":"Reading consumeFromWhere from a properties/YAML file into the enum with valueOf (throws earlier) or a lenient mapper returning null; sharing a config loader between DefaultMQPushConsumer (which allows the same three) and the lite consumer after adding a custom enum constant.","solutions":["Pass one of the three whitelisted constants, most commonly ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET","If the value comes from config, default it when null: Optional.ofNullable(cfg).orElse(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET)","Avoid adding custom constants to the ConsumeFromWhere enum — the setter rejects them"],"exampleFix":"// before\nconsumer.setConsumeFromWhere(ConsumeFromWhere.valueOf(userConfig)); // may be null/unknown\n\n// after\nConsumeFromWhere where = userConfig != null ? userConfig : ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET;\nconsumer.setConsumeFromWhere(where);","handlingStrategy":"validation","validationCode":"private static final Set<ConsumeFromWhere> LITE_VALID = EnumSet.of(\n    ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET,\n    ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET,\n    ConsumeFromWhere.CONSUME_FROM_TIMESTAMP);\n\nConsumeFromWhere safe = (cfg == null || !LITE_VALID.contains(cfg))\n    ? ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET : cfg;\nconsumer.setConsumeFromWhere(safe);","typeGuard":"static boolean isValidLiteConsumeFromWhere(ConsumeFromWhere v) {\n    return v == ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET\n        || v == ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET\n        || v == ConsumeFromWhere.CONSUME_FROM_TIMESTAMP;\n}","tryCatchPattern":null,"preventionTips":["Default null config values before calling the setter","Do not extend the ConsumeFromWhere enum","Keep config loaders typed to the enum, not raw strings"],"tags":["consumer","config","validation","enum"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}