Implement partition-level error injection for mock broker (#5491)
commit 39d7b52 ↗ · confluentinc/librdkafka · · committed Jun 24, 2026 · +469−57 · base 213f59c1ad70
Agent prompt
what a new run launched now would send
The mock cluster can already inject request errors at the cluster and broker level, but those mechanisms fail the whole request. Tests need finer control: inject a FIFO sequence of partition-level ErrorCodes for a specific topic partition and Kafka ApiKey, so other partitions in the same multi-partition request stay unaffected.
Requirements a teammate would be given upfront:
- Push N errors for (topic, partition, ApiKey); each matching request to that partition consumes the next error until the stack is empty, then succeeds again.
- Unknown topics may be auto-created (same as other mock partition APIs); an existing topic with an out-of-range partition must be rejected with UNKNOWN_TOPIC_OR_PART.
- Cluster- and broker-level injected errors take precedence over partition-level ones.
- Wire consumption into Produce, Fetch, ShareFetch, and ShareAcknowledge handlers. When a partition-level error is returned, suppress the side effect that error claims failed so mock state matches the response: no log append on Produce, no record acquisition / locked records on ShareFetch, no ack application on ShareAcknowledge.
- After the stack drains, subsequent requests to that partition succeed normally (transient injection).
Add coverage for API mechanics (auto-create vs bad partition, recovery after drain), ShareFetch errors scoped to one partition of a multi-partition topic, and ShareAcknowledge surfacing the injected error only on the targeted partition in commit_sync results.
Interface contract — the change must expose exactly this surface:
Export rd_kafka_mock_partition_push_request_errors(rd_kafka_mock_cluster_t *mcluster, const char *topic, int32_t partition, int16_t ApiKey, size_t cnt, ...) returning rd_kafka_resp_err_t; push cnt va-arg rd_kafka_resp_err_t values onto that partition's per-ApiKey error stack.
Work only inside this repository checkout. Make the code change the task
describes, keeping the diff focused — no drive-by refactors.
When you are done, leave your changes committed or in the working tree;
they are collected automatically.
Stay on this snapshot checkout (`task/ycb_librdkafka_c39d7b52917b2`). Never checkout, pull, or rebase onto `main`. That branch is a README-only orphan.
Stay on this HEAD. Do not fetch another default branch. Push only on the Cursor-created `crazy-cursor/…` side branch from this HEAD.
Some past runs of this task were launched with a different prompt (the prompt template changed since, or those runs predate this benchmark's stored prompt). Each run persists the exact prompt it sent at launch — that per-launch record is the audit trail; this page shows only the current one.
Reference diff
The task commit's diff against its first parent — the judge's comparison target.