# org.apache.kafka.common.errors.InvalidPartitionCountException：分区数必须大于 0。

- **ID:** `kafka/invalid-partition-count`
- **领域:** kafka
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 95%

## 根因

尝试创建或更改分区数为零或负数的主题，这是不允许的。

## 解决方案

1. ```
   Ensure partition count is a positive integer. Example fix: `kafka-topics.sh --bootstrap-server localhost:9092 --alter --topic my_topic --partitions 3` (never 0).
   ```

## 无效尝试

- **** — Setting partitions to 1 in a script that mistakenly passes 0 (e.g., from a default config) still fails; the fix is to validate input before the API call. (70% 失败率)
- **** — Using a negative value from a bug in partition calculation code (e.g., integer overflow) will still be rejected; the code must be fixed. (90% 失败率)
