Skip to content

chore(tests): prevent sentinel key collision in data-masking property test#5392

Open
svozza wants to merge 2 commits into
mainfrom
chore/data-masking-flaky-property-test
Open

chore(tests): prevent sentinel key collision in data-masking property test#5392
svozza wants to merge 2 commits into
mainfrom
chore/data-masking-flaky-property-test

Conversation

@svozza

@svozza svozza commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a flaky property test in the data-masking package, plus two latent instances of the same defect. The tests use hardcoded sentinel keys (id, keep) to assert that sibling fields survive masking, but the generated target field name could collide with the sentinel, collapsing both into one key. The masker then correctly masked it, and the assertion comparing against the sentinel failed. The erase utility itself behaves correctly; only the test generators were at fault.

The id collision surfaced in an unrelated CI run (counterexample ["a", "id", [""]]); the two keep collisions were found by auditing the remaining property tests for the same pattern.

Changes

  • Constrain the child-field generator in the [*] skips array elements missing the targeted field test to exclude "id", so it can never collide with the sentinel key
  • Apply the same constraint for the "keep" sentinel in the parent.*.child and parent[*].child tests, which had the identical latent collision

Issue number: closes #5391


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added size/XS PR between 0-9 LOC and removed size/XS PR between 0-9 LOC labels Jul 5, 2026
@sonarqubecloud

sonarqubecloud Bot commented Jul 5, 2026

Copy link
Copy Markdown

@svozza svozza requested a review from dreamorosi July 5, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS PR between 0-9 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Maintenance: fix flaky property test in data-masking erase tests

1 participant