{
  "id": "kafka/invalid-fetch-size",
  "signature": "org.apache.kafka.common.errors.InvalidFetchSizeException: Fetch size 0 is invalid",
  "signature_zh": "org.apache.kafka.common.errors.InvalidFetchSizeException: 获取大小0无效",
  "regex": "InvalidFetchSizeException.*Fetch size \\d+ is invalid",
  "domain": "kafka",
  "category": "protocol_error",
  "subcategory": null,
  "root_cause": "Consumer or follower fetch request specified a fetch size of 0 bytes, which is not allowed by the broker protocol.",
  "root_cause_type": "generic",
  "root_cause_zh": "消费者或跟随者获取请求指定了0字节的获取大小，代理协议不允许此操作。",
  "versions": [
    {
      "version": "Kafka 3.4.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Kafka 3.5.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Kafka 3.6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Set fetch.min.bytes to 1 instead of 0",
      "why_fails": "fetch.min.bytes controls minimum bytes before returning data, not the fetch size itself; setting to 1 may cause unnecessary polling.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "Disable fetch.max.bytes in consumer config",
      "why_fails": "Removing the config may default to 0 in some clients, causing the same error.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Upgrade Kafka client to latest version",
      "why_fails": "The issue is often a misconfigured client, not a bug; upgrading may not fix if config is wrong.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Set fetch.max.bytes to a positive value (e.g., 52428800) in consumer properties.\nExample:\nproperties.put(ConsumerConfig.FETCH_MAX_BYTES_CONFIG, 52428800);\nproperties.put(ConsumerConfig.MAX_PARTITION_FETCH_BYTES_CONFIG, 1048576);\n# Also ensure fetch.min.bytes is > 0\nproperties.put(ConsumerConfig.FETCH_MIN_BYTES_CONFIG, 1);",
      "success_rate": 0.8,
      "how": "Set fetch.max.bytes to a positive value (e.g., 52428800) in consumer properties.\nExample:\nproperties.put(ConsumerConfig.FETCH_MAX_BYTES_CONFIG, 52428800);\nproperties.put(ConsumerConfig.MAX_PARTITION_FETCH_BYTES_CONFIG, 1048576);\n# Also ensure fetch.min.bytes is > 0\nproperties.put(ConsumerConfig.FETCH_MIN_BYTES_CONFIG, 1);",
      "condition": "",
      "sources": []
    },
    {
      "action": "If using Kafka Streams, ensure 'fetch.max.bytes' is set in StreamsConfig.\nCommand to check current config:\nkafka-consumer-groups --bootstrap-server localhost:9092 --group my-group --describe\n# If fetch.max.bytes is 0, override in properties:\nprops.put(StreamsConfig.consumerPrefix(ConsumerConfig.FETCH_MAX_BYTES_CONFIG), 52428800);",
      "success_rate": 0.75,
      "how": "If using Kafka Streams, ensure 'fetch.max.bytes' is set in StreamsConfig.\nCommand to check current config:\nkafka-consumer-groups --bootstrap-server localhost:9092 --group my-group --describe\n# If fetch.max.bytes is 0, override in properties:\nprops.put(StreamsConfig.consumerPrefix(ConsumerConfig.FETCH_MAX_BYTES_CONFIG), 52428800);",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Set fetch.max.bytes to a positive value (e.g., 52428800) in consumer properties.\nExample:\nproperties.put(ConsumerConfig.FETCH_MAX_BYTES_CONFIG, 52428800);\nproperties.put(ConsumerConfig.MAX_PARTITION_FETCH_BYTES_CONFIG, 1048576);\n# Also ensure fetch.min.bytes is > 0\nproperties.put(ConsumerConfig.FETCH_MIN_BYTES_CONFIG, 1);",
    "If using Kafka Streams, ensure 'fetch.max.bytes' is set in StreamsConfig.\nCommand to check current config:\nkafka-consumer-groups --bootstrap-server localhost:9092 --group my-group --describe\n# If fetch.max.bytes is 0, override in properties:\nprops.put(StreamsConfig.consumerPrefix(ConsumerConfig.FETCH_MAX_BYTES_CONFIG), 52428800);"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://kafka.apache.org/documentation/#consumerconfigs_fetch.message.max.bytes",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-06-12",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}