apache/pulsar · warning · UnsupportedOperationException
Context does not provide SubscriptionType
Error message
Context does not provide SubscriptionType
What it means
SinkContext.getSubscriptionType() is a default interface method that throws UnsupportedOperationException because the base SinkContext contract does not expose the subscription type of the consuming subscription. It is thrown only when the concrete runtime context (e.g. the functions instance) does not override it. A sink calling this method on such a context cannot learn the SubscriptionType.
Source
Thrown at pulsar-io/core/src/main/java/org/apache/pulsar/io/core/SinkContext.java:63
*
* @return a list of all input topics
*/
Collection<String> getInputTopics();
/**
* Get sink config at startup.
*
* @return sink config
*/
SinkConfig getSinkConfig();
/**
* Get subscription type used by the source providing data for the sink.
*
* @return subscription type
*/
default SubscriptionType getSubscriptionType() {
throw new UnsupportedOperationException("Context does not provide SubscriptionType");
}
/**
* Reset the subscription associated with this topic and partition to a specific message id.
*
* @param topic - topic name
* @param partition - partition id (0 for non-partitioned topics)
* @param messageId to reset to
* @throws PulsarClientException
*/
default void seek(String topic, int partition, MessageId messageId) throws PulsarClientException {
throw new UnsupportedOperationException("not implemented");
}
/**
* Stop requesting new messages for given topic and partition until {@link #resume(String topic, int partition)}
* is called.
*View on GitHub (pinned to 820761864e)
Solutions
- Upgrade the Pulsar runtime/worker to a version whose SinkContext implementation provides getSubscriptionType.
- In connector code, catch UnsupportedOperationException and fall back to a configured or default subscription type.
- In tests, use a stub that overrides getSubscriptionType with the expected value.
Example fix
// before
SubscriptionType type = ctx.getSubscriptionType();
// after
SubscriptionType type;
try {
type = ctx.getSubscriptionType();
} catch (UnsupportedOperationException e) {
type = SubscriptionType.Shared; // configurable fallback
} Defensive patterns
Strategy: try-catch
Try / catch
try {
SubscriptionType t = ctx.getSubscriptionType();
} catch (UnsupportedOperationException e) {
SubscriptionType t = SubscriptionType.Shared; // documented fallback
} Prevention
- Pin connector runtime compatibility with the broker/worker Pulsar version
- Never assume SinkContext optional methods exist; code defensively
- Test connectors against a real functions runtime, not only stubs
When it happens
Trigger: Calling sinkContext.getSubscriptionType() inside a Pulsar IO sink when the runtime implementation of SinkContext has not implemented this method (older broker/worker version or a test/mock context).
Common situations: Connector code using the newer SinkContext API against an older Pulsar runtime; unit tests using a stub SinkContext that doesn't override getSubscriptionType (e.g. testGetSubscriptionType failures); embedding the sink outside a real functions runtime.
Related errors
- not implemented
- BookKeeper client is not available
- Package Management Service is not enabled in the broker.
- Expire message by timestamp is not supported for non-persist
- Expire message by position is not supported for non-persiste
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/7d0577137c8263c7.
Report an issue: GitHub.