apache/pulsar · error · IllegalArgumentException
Unrecognized auto_failover_policy: ${policyType}
Error message
Unrecognized auto_failover_policy: ${policyType} What it means
AutoFailoverPolicyFactory.create throws IllegalArgumentException when the policy type in AutoFailoverPolicyData is anything other than min_available, the only policy type currently supported. Only MinAvailablePolicy can be constructed.
Source
Thrown at pulsar-client-admin-api/src/main/java/org/apache/pulsar/common/policies/impl/AutoFailoverPolicyFactory.java:34
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.pulsar.common.policies.impl;
import org.apache.pulsar.common.policies.AutoFailoverPolicy;
import org.apache.pulsar.common.policies.data.AutoFailoverPolicyData;
import org.apache.pulsar.common.policies.data.AutoFailoverPolicyType;
/**
* Factory to generate an instance of {@link AutoFailoverPolicy}.
*/
public class AutoFailoverPolicyFactory {
public static AutoFailoverPolicy create(AutoFailoverPolicyData policyData) {
// TODO: Add more policy types when needed
if (!AutoFailoverPolicyType.min_available.equals(policyData.getPolicyType())) {
// right now, only support one type of policy: MinAvailablePolicy
throw new IllegalArgumentException("Unrecognized auto_failover_policy: " + policyData.getPolicyType());
}
return new MinAvailablePolicy(policyData);
}
}
View on GitHub (pinned to 820761864e)
Solutions
- Set policyData.setPolicyType(AutoFailoverPolicyType.min_available) before calling create
- In JSON configs, ensure auto_failover_policy_type is present and exactly 'min_available'
- Validate policyData.getPolicyType() != null before invoking create
Example fix
// before AutoFailoverPolicyData data = new AutoFailoverPolicyData(); data.setMinLimit(1); AutoFailoverPolicy policy = AutoFailoverPolicyFactory.create(data); // throws // after AutoFailoverPolicyData data = new AutoFailoverPolicyData(); data.setPolicyType(AutoFailoverPolicyType.min_available); data.setMinLimit(1); AutoFailoverPolicy policy = AutoFailoverPolicyFactory.create(data);
Defensive patterns
Strategy: validation
Validate before calling
if (policyData.getPolicyType() != AutoFailoverPolicyType.min_available) {
throw new IllegalArgumentException("only min_available auto-failover policy is supported");
} Try / catch
try {
AutoFailoverPolicy policy = AutoFailoverPolicyFactory.create(policyData);
} catch (IllegalArgumentException e) {
logger.error("Unsupported failover policy type {}", policyData.getPolicyType());
} Prevention
- Always set policyType explicitly via AutoFailoverPolicyType.min_available
- Check JSON policy payloads include auto_failover_policy_type
- Remember only min_available exists — don't invent other types from docs or other systems
When it happens
Trigger: Calling AutoFailoverPolicy.create(policyData) — often via namespace isolation or resource-group admin flows — with policyData.policyType set to null or a value other than AutoFailoverPolicyType.min_available (e.g. deserialized from JSON missing the policyType field).
Common situations: Hand-written JSON for namespace isolation policies omitting or misspelling auto_failover_policy_type, config migrated from docs showing other policy types, or default-constructed AutoFailoverPolicyData with unset policyType.
Related errors
- Not support component type
- configuredService should not be an instance of SystemTopicBa
- Invalid auto split/merge configuration: ${message}
- Unknown resource type:
- The shared resource doesn't support thread pool configurati
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/ee580094490e01cb.
Report an issue: GitHub.