Fix WithRedactionKeys validation inconsistency#44
Closed
Copilot wants to merge 3 commits intofeat/secretsfrom
Closed
Fix WithRedactionKeys validation inconsistency#44Copilot wants to merge 3 commits intofeat/secretsfrom
Copilot wants to merge 3 commits intofeat/secretsfrom
Conversation
Co-authored-by: hyp3rd <62474964+hyp3rd@users.noreply.github.com>
Co-authored-by: hyp3rd <62474964+hyp3rd@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix issues in secrets detection and redaction package based on review
Fix WithRedactionKeys validation inconsistency
Jan 12, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a validation inconsistency in WithRedactionKeys where all-whitespace keys would fail validation only when no default keys existed, but succeed when default keys were present. The fix tracks the count of valid keys actually added from the input and validates against this count, ensuring consistent behavior regardless of the initialization state.
Changes:
- Modified
WithRedactionKeysto trackaddedCountof normalized keys that were actually added, validating against this instead of the total keys in the configuration - Updated documentation to clarify that validation is consistent regardless of existing keys
- Added comprehensive test coverage for edge cases including all-whitespace keys, empty keys, valid keys, and mixed valid/invalid keys
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/secrets/redact.go | Fixed validation logic to use addedCount instead of len(cfg.keys) and updated documentation to reflect consistent validation behavior |
| pkg/secrets/secrets_test.go | Added TestWithRedactionKeysValidation with comprehensive test cases for the validation edge cases |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
WithRedactionKeysvalidation exhibited inconsistent behavior: passing all-whitespace keys would fail if no default keys existed, but succeed if default keys were present. This created unpredictable behavior based on initialization state.Changes
addedCountof normalized keys actually added, validate against this instead of total key countExample
Test coverage added for edge cases: all-whitespace keys, mixed valid/invalid keys.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.