Conversation
… overlapping prefix/suffix wildcards Agent-Logs-Url: https://github.com/github/gh-aw/sessions/c74ec611-e731-43e9-bc12-db4771175f78 Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/c74ec611-e731-43e9-bc12-db4771175f78 Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes matchPattern incorrectly returning true for middle-wildcard patterns when the required prefix+suffix would have to overlap (e.g., "ab*ba" matching "aba").
Changes:
- Add a length guard in the middle-wildcard branch of
matchPatternto prevent overlap-based false positives. - Add
TestMatchPatterncases for the overlapping scenario (should not match) and the exact-boundary scenario (should match).
Show a summary per file
| File | Description |
|---|---|
| pkg/logger/logger.go | Adds len(namespace) >= len(prefix)+len(suffix) guard for middle * patterns to avoid overlapping prefix/suffix matches. |
| pkg/logger/logger_test.go | Adds regression tests covering overlapping and exact-boundary middle-wildcard matching. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 0
🧪 Test Quality Sentinel ReportTest Quality Score: 100/100✅ Excellent test quality
Test Classification Details
AnalysisBoth added test cases are new rows in the existing Classification: Design tests — they assert observable return values of Edge case coverage: ✅ The overlapping case ( Assertion quality: Uses Build tag: Mock libraries: None. ✅ Language SupportTests analyzed:
Verdict
📖 Understanding Test ClassificationsDesign Tests (High Value) verify what the system does:
Implementation Tests (Low Value) verify how the system does it:
Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators. References: §25079858155
|
matchPatterninpkg/logger/logger.goincorrectly matches namespaces against middle-wildcard patterns when the prefix and suffix overlap (e.g. pattern"ab*ba"matches"aba"becauseHasPrefixandHasSuffixchecks pass independently, even though the string is too short to satisfy both non-overlapping).Changes
pkg/logger/logger.go: Addlen(namespace) >= len(prefix)+len(suffix)guard before the prefix/suffix checks in the middle-wildcard branch:pkg/logger/logger_test.go: Add two test cases toTestMatchPatterncovering the overlapping case ("aba"vs"ab*ba"→false) and the exact-boundary case ("abba"vs"ab*ba"→true).