Kafka Exception PolicyViolationException
org.apache.kafka.common.errors.PolicyViolationException
Non-retriable
Admin
Exception thrown if a create topics request does not satisfy the configured policy for a topic.
Common Causes
- CreateTopicPolicy or AlterConfigPolicy plugin installed on the broker is rejecting the request (e.g., naming convention not met, min replication factor not satisfied)
- Topic creation request violates cluster-wide constraints enforced via a custom policy class configured in create.topic.policy.class.name
- Alter config request attempting to set a value outside the range allowed by the broker's policy (e.g., lowering retention below a minimum floor)
Solutions
- Check broker logs for the specific policy rejection message — the policy class typically logs a human-readable reason
- Review the policy class configured in create.topic.policy.class.name or alter.config.policy.class.name and adjust the request to comply
- Contact the Kafka admin team to understand enforced naming/configuration policies; document them in runbooks to prevent recurrence
Example Stack Trace
org.apache.kafka.common.errors.PolicyViolationException: Request parameters do not satisfy the configured policy.Diagnostic Commands
# Look for policy violation events in logs
grep 'POLICY_VIOLATION\|PolicyViolation\|policy' /var/log/kafka/server.log | tail -20
# Check broker policy configuration
kafka-configs.sh --bootstrap-server localhost:9092 --entity-type brokers --entity-default --describe | grep policyRelated
Protocol error: POLICY_VIOLATION (code 44)
Related Admin exceptions: InvalidConfigurationException · InvalidPartitionsException · InvalidReplicationFactorException · InvalidTopicException · ThrottlingQuotaExceededException · TopicExistsException · UnsupportedVersionException
Hitting
PolicyViolationException in production? Conduktor Console gives you real-time visibility into clients, consumer groups, and broker health. Browse every Kafka exception or protocol error code.