apache/pulsar · error · RuntimeException

Unknown consumer protobuf failure action

Error message

Unknown consumer protobuf failure action 

What it means

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.

Source

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

                return ProducerCryptoFailureAction.FAIL;
            case SEND:
                return ProducerCryptoFailureAction.SEND;
            default:
                throw new RuntimeException(
                        "Unknown producer protobuf failure action " + action.name());
        }
    }

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

    public static CryptoSpec.FailureAction getProtoFailureAction(ProducerCryptoFailureAction action) {
        switch (action) {
            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:

View on GitHub (pinned to 820761864e)

Solutions

  1. Set the consumer's CryptoSpec failureAction to FAIL, DISCARD, or CONSUME only
  2. Use getProducerCryptoFailureAction for producer specs (valid values FAIL/SEND)
  3. Upgrade/align Pulsar client and functions-utils versions if a new enum value was introduced

Example fix

// before
cryptoSpec.setFailureAction(CryptoSpec.FailureAction.SEND); // producer-only
// after
cryptoSpec.setFailureAction(CryptoSpec.FailureAction.CONSUME); // valid for consumer
Defensive patterns

Strategy: validation

Validate before calling

if (action != CryptoSpec.FailureAction.FAIL
        && action != CryptoSpec.FailureAction.DISCARD
        && action != CryptoSpec.FailureAction.CONSUME) {
    throw new IllegalArgumentException("Consumer failureAction must be FAIL, DISCARD, or CONSUME, got " + action);
}

Type guard

boolean isConsumerAction(CryptoSpec.FailureAction a) {
    return a == CryptoSpec.FailureAction.FAIL
        || a == CryptoSpec.FailureAction.DISCARD
        || a == CryptoSpec.FailureAction.CONSUME;
}

Try / catch

try {
    ConsumerCryptoFailureAction mapped = CryptoUtils.getConsumerCryptoFailureAction(action);
} catch (RuntimeException e) {
    log.warn("Unsupported consumer failure action, defaulting to DISCARD", e);
    ConsumerCryptoFailureAction mapped = ConsumerCryptoFailureAction.DISCARD;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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