mattp5657 opened a new pull request, #4362:
URL: https://github.com/apache/iggy/pull/4362
# PR description draft: field-mapping clone-before-clear
Draft body for the PR closing
[issue-field-mapping-clone-before-clear.md](issue-field-mapping-clone-before-clear.md).
Copy into the PR; fill in the real issue number.
---
## Which issue does this PR address?
Closes #4307
## Rationale
Eight sites renamed JSON keys for `field_mappings` by cloning every
key/value into a side buffer, clearing the map, then reinserting —
copying data that was already about to be dropped.
## What changed?
New `convert::apply_field_mappings` helper (`.drain()`s the map instead
of cloning); all 8 sites now call it. Behavior is byte-for-byte
identical to `master`, including on a collision — same outcome, just via
a move instead of a clone. No new error paths, no signature changes.
**Out of scope:** a rename collision (two keys onto the same target, or
a duplicate key already in the payload) still silently keeps one value
and drops the other, same as `master`. Which value survives is
deterministic on small objects but unspecified once `simd_json` swaps
to its hash-backed map. Pre-existing, not introduced by this PR. Filing
a follow-up issue for how these collisions should be handled and
whether `field_mappings` validation should be systematic across all 9
config types (0 covered today).
## Test coverage
Fixed one vacuous test (`decoders/proto.rs` configured `use_any_wrapper`
with no schema, so `field_mappings` was never actually exercised —
rewritten against a real schema). Strengthened several tests that only
checked key presence/absence to also assert the renamed value survived.
Added a collision test and a 40-key test covering `simd_json`'s
backing-map swap.
## Local Execution
- `cargo test -p iggy_connector_sdk` (202 unit + 10 flatbuffer + 21
proto integration) and `-p iggy-connectors` (237): passing.
- `fmt` / `sort` / `clippy -D warnings` / license/whitespace/newline
scripts: clean.
## AI Usage
1. **Tools:** Claude
2. **Use:** `.drain()` rewrite across all 8 sites, shared helper.
3. **Verification:** Full local test suite.
4. Reviewed and can explain every line if asked.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]