apache/pulsar · error · RuntimeException

Unknown consumer crypto failure action

Error message

Unknown consumer crypto failure action 

What it means

CryptoUtils.getProtoFailureAction(ConsumerCryptoFailureAction) converts the client's consumer enum into CryptoSpec.FailureAction, supporting FAIL, DISCARD, and CONSUME. Any other ConsumerCryptoFailureAction value throws this RuntimeException. This is the reverse mapping of getConsumerCryptoFailureAction.

Solutions

  1. Use only FAIL, DISCARD, or CONSUME for consumer failure actions
  2. Align client, broker, and functions-utils versions
  3. Regenerate or fix the crypto spec with a supported enum value

Example fix

// before
consumerAction = ConsumerCryptoFailureAction.RECONNECT; // unsupported
// after
consumerAction = ConsumerCryptoFailureAction.DISCARD;
Defensive patterns

Strategy: validation

Validate before calling

if (action != ConsumerCryptoFailureAction.FAIL
        && action != ConsumerCryptoFailureAction.DISCARD
        && action != ConsumerCryptoFailureAction.CONSUME) {
    throw new IllegalArgumentException("Unsupported consumer action for conversion: " + action);
}

Try / catch

try {
    CryptoSpec.FailureAction spec = CryptoUtils.getProtoFailureAction(consumerAction);
} catch (RuntimeException e) {
    log.error("Consumer action not convertible; falling back to DISCARD", e);
    CryptoSpec.FailureAction spec = CryptoSpec.FailureAction.DISCARD;
}

Prevention

When it happens

Trigger: Calling convert()/convertFromSpec paths that invoke getProtoFailureAction with a consumer failure action outside {FAIL, DISCARD, CONSUME}, typically a value added by a newer client library than the code performing the conversion.

Common situations: Version skew between the component that produced the function/crypto spec and the one converting it; hand-edited configs; new enum constants not yet present in the deployed Pulsar version.

Related errors


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/5d11114f76b72b25. Report an issue: GitHub.

Appendix: source

Thrown at pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/CryptoUtils.java:157

            case FAIL:
                return CryptoSpec.FailureAction.FAIL;
            case SEND:
                return CryptoSpec.FailureAction.SEND;
            default:
                throw new RuntimeException("Unknown producer crypto failure action " + action);
        }
    }

    public static CryptoSpec.FailureAction getProtoFailureAction(ConsumerCryptoFailureAction action) {
        switch (action) {
            case FAIL:
                return CryptoSpec.FailureAction.FAIL;
            case DISCARD:
                return CryptoSpec.FailureAction.DISCARD;
            case CONSUME:
                return CryptoSpec.FailureAction.CONSUME;
            default:
                throw new RuntimeException("Unknown consumer crypto failure action " + action);
        }
    }

}

View on GitHub (pinned to 820761864e)