Skip to content

[gateway] Reject duplicate MAP keys in entry arrays - #4205

Open
Gezi-lzq wants to merge 1 commit into
apache:mainfrom
Gezi-lzq:codex/fluss-4204-map-duplicate-keys
Open

[gateway] Reject duplicate MAP keys in entry arrays#4205
Gezi-lzq wants to merge 1 commit into
apache:mainfrom
Gezi-lzq:codex/fluss-4204-map-duplicate-keys

Conversation

@Gezi-lzq

@Gezi-lzq Gezi-lzq commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Purpose

Linked issue: close #4204

Canonical MAP entry arrays currently accept duplicate decoded keys. When such a row is read, a later value can silently overwrite an earlier value. This change rejects the invalid MAP at the Gateway REST boundary.

Brief change log

  • Detect duplicate keys after canonical MAP entries have been decoded to their declared key type.
  • Report the second occurrence with its precise v[index].key path as an invalid value.
  • Add regression coverage for non-adjacent string duplicates and semantically equal integer keys (7 and "7").

Tests

  • cargo test --all-targets
  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings -A clippy::needless_borrows_for_generic_args -A clippy::uninlined_format_args
  • git diff --check

API and Format

No public API or storage format changes. Invalid canonical MAP entry arrays with duplicate keys now return HTTP 400 instead of being written.

Documentation

No documentation changes. This fixes validation of an existing API contract.

Reject duplicate decoded keys before encoding canonical MAP entry arrays so later values cannot silently overwrite earlier entries.

@naivedogger naivedogger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. Thanks for catching this. Comparing keys after schema-aware decoding is the right approach, since it also catches equivalent JSON representations such as 7 and "7". The implementation and tests look good to me. cc @beryllw

@beryllw beryllw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[gateway] Canonical MAP entry arrays accept duplicate keys

3 participants