fix: reject duplicate normalized rate-limit identifier keys

What

Validate Labkit::RateLimit::Identifier attribute keys during normalization.

  • Reject keys that do not respond to #to_sym with InvalidKeyError.
  • Reject distinct keys that normalize to the same symbol with DuplicateNormalizedKeyError.
  • Preserve string and symbol key support, endpoint normalization, and immutable attributes.

This prevents hashes such as { user: 1, "user" => 2 } from silently selecting a rate-limit bucket based on insertion order.

Why

transform_keys(&:to_sym) silently overwrites normalized-key collisions. The resulting identifier, and therefore rate-limit bucket, depended on which duplicate key appeared last.

Invalid non-symbolizable keys previously exposed an incidental NoMethodError rather than a domain-specific input error.

Merge request reports

Loading
Loading