On this page
Kafka troubleshooting
InvalidRequestException (INVALID_REQUEST)
org.
The broker answered INVALID_REQUEST (error code 42) because the request breaks basic wire protocol rules: a field is missing, set where it must not be, or contradicts another field. Kafka says it most likely comes from a client library that built the request wrong, or from a request sent to an incompatible broker. The broker log and the error message say which rule the request broke.
Reproduce it in the playground2 steps beforeRipcord is on; the control plane goes down. t+2.050s
orders is a WarpStream topic (Agent v857). Three Agents run here, one per zone, with Ripcord on. p-a (ws_az=az-a) writes through agent-1 and p-c (ws_az=az-c) through agent-3, both with idempotence off; p-idem in az-b is idempotent. The first records, k1 from p-a and k2 from p-c, were committed by the control plane at 1450 and acked: k1 got offset 0 of partition 2 and k2 offset 0 of partition 1. g1's consumer c1 in az-a read them at 1800. At 2000 the control plane stops, and the Agents notice at once (the simulator's choice). Without Ripcord, produce would now be rejected.
Open at this step: step 1, Ripcord is on; the control plane goes down1 step beforeProduce goes on: acked with offset 0, kept in a journal. t+3.700s
At 2100 p-c sends k3, and at 2500 p-a sends k4, both to partition 2. Each Agent buffers and uploads a file as usual. agent-3's file with k3 is in object storage at 3250, and agent-1's file with k4 at 3650. With Ripcord the Agent acks once the file is written: p-c is acked at 3250 and p-a at 3650, each with offset 0. That is not the record's offset (offset 0 of partition 2 is k1): nothing can be committed, so each file goes into a journal, to be committed when the control plane returns. Partition 2's high watermark stays at 1.
Open at this step: step 2, Produce goes on: acked with offset 0, kept in a journalThe moment it happensAn idempotent producer is refused under Ripcord. t+3.900s
At 3800 p-idem, an idempotent producer, sends k5. At 3850 it is refused with INVALID_REQUEST, and the record reaches no Agent. WarpStream's docs say idempotence and transactions must be off for Ripcord, but not how a producer that has them on is answered: the refusal and the code are the simulator's choices. INVALID_REQUEST is not retriable, so p-idem stops with an error.
Open at this step: step 3, An idempotent producer is refused under RipcordRight afterConsumers wait: nothing journaled is readable yet. t+4.250s
WarpStream's docs say consumers stop under Ripcord: the list of files to read comes from the control plane, and a journaled file has no offsets yet. c1 polled at 2400, 3000, 3600 and 4200. Each fetch failed with REQUEST_TIMED_OUT on every partition, and each try to commit what it read at 1800 failed with COORDINATOR_NOT_AVAILABLE (the docs name no codes; both are the simulator's choice). k3 and k4 are acked, yet no consumer can read them: partition 2's high watermark is still 1.
Open at this step: step 4, Consumers wait: nothing journaled is readable yetWhat it means
InvalidRequestException is how an Apache Kafka 4.4 broker or controller refuses a request that is well formed bytes but not a valid request. Its javadoc says it is thrown when a request breaks basic wire protocol rules, and the description of INVALID_REQUEST in Errors.java says it most likely occurs because the client library malformed the request or the message went to an incompatible broker, and points at the broker logs. Applications on the official clients rarely see it. It shows up with third-party clients, with tools that build requests by hand, and with admin calls whose fields are checked against each other: an incremental config change that sets a config to null instead of deleting it, the same config key twice for one resource, or a CreateTopics request that gives a manual replica assignment and also a partition count or a replication factor. The admin client sees the exception as the cause of the ExecutionException its request's future fails with; a producer gets it in its send callback, and the send is not retried. WarpStream, a Kafka-compatible system, limits idempotence and transactions in two places: its Ripcord page asks for both to be off, and its lightning topics page says such produce is rejected. Neither names an error code. In the simulator such a producer is refused with INVALID_REQUEST; the code is the simulator's choice in both cases, and so is the refusal under Ripcord. Scenarios 10.1.5 (Ripcord) and 10.1.6 (lightning topics) show it. StreamNative Ursa for Kafka, a Kafka-compatible system with diskless and disk topics in one cluster, names this code itself: a produce from a transactional producer to a diskless topic is rejected with INVALID_REQUEST, as Ursa does not support transactions on diskless topics yet (its docs say "coming soon"); disk topics take transactions as Apache Kafka does. Scenario 13.1.5 shows it.
Likely causes, most common first
- A client library that builds the request wrong. A third-party or outdated client, or a tool that writes requests by hand, sends a request whose fields break the protocol rules for its API version, or sends a request to an incompatible broker. With the official Java clients the error more often points at an admin call whose fields contradict each other.
- A config change with a null value or a repeated key. An incremental alter of a topic or broker config sets a config to null with an operation other than DELETE ("Null value not supported for"), or names the same config key twice for one resource ("Error due to duplicate config keys"). The broker refuses that resource's change before it reaches the controller; other resources in the same request still go through. A value the config does not accept is a different error, INVALID_CONFIG.
- A topic created with an assignment and counts. A CreateTopics request gives a manual replica assignment and also a partition count or a replication factor other than -1. The controller refuses the topic: with a manual assignment both must be -1, since the assignment already fixes them. The Java admin client's NewTopic sets them to -1 when it takes an assignment, so this comes from requests built some other way.
- WarpStream in the simulator: an idempotent producer under Ripcord or on a lightning topic. On a WarpStream cluster in the simulator with Ripcord on, while the control plane is unreachable, a producer with enable.idempotence=true or a transactional.id is refused with INVALID_REQUEST, and so is such a producer writing a lightning topic at any time. WarpStream's Ripcord page says both must be off, and its lightning topics page says such produce is rejected; neither names an error, so the code is the simulator's choice. Producers default to enable.idempotence=true since Kafka 3.0, so a producer is idempotent unless it sets enable.idempotence=false or, with enable.idempotence left unset, a conflicting setting (acks=0 or 1, retries=0, or max.in.flight.requests.per.connection above 5) turns it off.
- Ursa for Kafka: a transactional producer on a diskless topic. On an Ursa for Kafka cluster, a producer with a transactional.id that writes a diskless topic (ursa.storage.enable=true) gets INVALID_REQUEST on its first produce, and the record is not written. Idempotent producers without a transactional.id are supported on diskless topics. The same producer writing a disk topic of the same cluster commits its transactions.
How to fix it
- Read the error message and the broker log: they name the rule the request broke, for example the config key with a null value.
- Upgrade the client library, or align it with the broker version, if the request comes from a third-party or old client; report a reproducible case to its maintainers.
- Remove a config with an incremental alter of type DELETE, or kafka-configs.sh --delete-config, instead of setting it to null, and name each config key once per resource.
- Create a topic either with a partition count and a replication factor, or with a manual replica assignment and both left at -1, never with both.
- On WarpStream with Ripcord, or for a lightning topic, set enable.idempotence=false and remove transactional.id on the producer; in the simulator, the refused record is not written, so send it again after the change.
- On Ursa for Kafka, write transactions to a disk topic, or remove transactional.id on the producers of a diskless topic.
What not to do
- Retrying the same request in a loop: the error is not retriable, and the request fails the same way until it changes.
- Turning off idempotence on every producer to make the error go away: on Apache Kafka it is needed for no-duplicate retries, and only WarpStream's Ripcord and lightning topics ask for it off.
Does the client retry it?
No. INVALID_REQUEST (error code 42) is not retriable: InvalidRequestException extends ApiException, not RetriableException, and the same request gets the same answer every time. Change the request, or the client that builds it, then send it again.
Reproduce it in the simulator
- WarpStream Kafka Ripcord: produce without the control plane (WarpStream: Ripcord) Open at the moment it happens: WarpStream Kafka Ripcord: produce without the control plane
- WarpStream Kafka lightning topics: ack before the commit (WarpStream: lightning topics) Open at the moment it happens: WarpStream Kafka lightning topics: ack before the commit
- Ursa for Kafka: diskless and disk topics, side by side (Ursa for Kafka: diskless and disk topics side by side) Open at the moment it happens: Ursa for Kafka: diskless and disk topics, side by side
Sources
- Apache Kafka 4.4 javadoc: InvalidRequestException
- Apache Kafka 4.4.0 source: Errors.java (INVALID_REQUEST, code 42)
- Apache Kafka 4.4.0 source: ConfigAdminManager.scala (null values, duplicate config keys)
- Apache Kafka 4.4.0 source: ReplicationControlManager.java (a manual assignment with counts)
- KIP-679: the producer enables idempotence by default
- WarpStream docs: Ripcord (idempotence and transactions must be off)
- WarpStream docs: lightning topics
- StreamNative: Ursa for Kafka deep dive, write path, read path and data compaction (transactional producers rejected with INVALID_REQUEST)
- StreamNative docs: cluster profiles (transactions on diskless topics coming soon)
- StreamNative docs: Kafka cluster guide (disk topics with transactions)