{"record":{"id":"844aefb7767f8a1e","repo":"apache/pulsar","slug":"unknown-consumer-protobuf-failure-action","errorCode":null,"errorMessage":"Unknown consumer protobuf failure action ","messagePattern":"Unknown consumer protobuf failure action ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/CryptoUtils.java","lineNumber":132,"sourceCode":"                return ProducerCryptoFailureAction.FAIL;\n            case SEND:\n                return ProducerCryptoFailureAction.SEND;\n            default:\n                throw new RuntimeException(\n                        \"Unknown producer protobuf failure action \" + action.name());\n        }\n    }\n\n    public static ConsumerCryptoFailureAction getConsumerCryptoFailureAction(CryptoSpec.FailureAction action) {\n        switch (action) {\n            case FAIL:\n                return ConsumerCryptoFailureAction.FAIL;\n            case DISCARD:\n                return ConsumerCryptoFailureAction.DISCARD;\n            case CONSUME:\n                return ConsumerCryptoFailureAction.CONSUME;\n            default:\n                throw new RuntimeException(\n                        \"Unknown consumer protobuf failure action \" + action.name());\n        }\n    }\n\n    public static CryptoSpec.FailureAction getProtoFailureAction(ProducerCryptoFailureAction action) {\n        switch (action) {\n            case FAIL:\n                return CryptoSpec.FailureAction.FAIL;\n            case SEND:\n                return CryptoSpec.FailureAction.SEND;\n            default:\n                throw new RuntimeException(\"Unknown producer crypto failure action \" + action);\n        }\n    }\n\n    public static CryptoSpec.FailureAction getProtoFailureAction(ConsumerCryptoFailureAction action) {\n        switch (action) {\n            case FAIL:","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/CryptoUtils.java#L114-L150","documentation":"CryptoUtils.getConsumerCryptoFailureAction maps a CryptoSpec.FailureAction to the client's ConsumerCryptoFailureAction, handling FAIL, DISCARD, and CONSUME. Any other value — typically a producer-only action like SEND — is unsupported and throws this RuntimeException. It signals a consumer crypto spec populated with an invalid failure action.","triggerScenarios":"Calling getConsumerCryptoFailureAction (via convertFromSpec) with a CryptoSpec.FailureAction value of SEND or any other non-consumer action, or an enum constant added in a newer version not known to this code.","commonSituations":"Reusing a producer crypto spec for a consumer; generated/validated-but-wrong config files; mixed Pulsar versions where a new FailureAction exists on one side but not the converter.","solutions":["Set the consumer's CryptoSpec failureAction to FAIL, DISCARD, or CONSUME only","Use getProducerCryptoFailureAction for producer specs (valid values FAIL/SEND)","Upgrade/align Pulsar client and functions-utils versions if a new enum value was introduced"],"exampleFix":"// before\ncryptoSpec.setFailureAction(CryptoSpec.FailureAction.SEND); // producer-only\n// after\ncryptoSpec.setFailureAction(CryptoSpec.FailureAction.CONSUME); // valid for consumer","handlingStrategy":"validation","validationCode":"if (action != CryptoSpec.FailureAction.FAIL\n        && action != CryptoSpec.FailureAction.DISCARD\n        && action != CryptoSpec.FailureAction.CONSUME) {\n    throw new IllegalArgumentException(\"Consumer failureAction must be FAIL, DISCARD, or CONSUME, got \" + action);\n}","typeGuard":"boolean isConsumerAction(CryptoSpec.FailureAction a) {\n    return a == CryptoSpec.FailureAction.FAIL\n        || a == CryptoSpec.FailureAction.DISCARD\n        || a == CryptoSpec.FailureAction.CONSUME;\n}","tryCatchPattern":"try {\n    ConsumerCryptoFailureAction mapped = CryptoUtils.getConsumerCryptoFailureAction(action);\n} catch (RuntimeException e) {\n    log.warn(\"Unsupported consumer failure action, defaulting to DISCARD\", e);\n    ConsumerCryptoFailureAction mapped = ConsumerCryptoFailureAction.DISCARD;\n}","preventionTips":["Only set FAIL, DISCARD, or CONSUME in consumer crypto specs","Use separate spec builders for producer and consumer crypto","Keep Pulsar versions aligned across CLI, client, and worker","Validate the crypto spec before calling convertFromSpec"],"tags":["enum","crypto","configuration","mapping"],"backgroundTag":"unsupported-enum-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"}