Skip to content

Trim whitespace from --include/--exclude patterns#238

Merged
winebarrel merged 2 commits into
mainfrom
trim-filter-patterns
May 22, 2026
Merged

Trim whitespace from --include/--exclude patterns#238
winebarrel merged 2 commits into
mainfrom
trim-filter-patterns

Conversation

@winebarrel
Copy link
Copy Markdown
Owner

Summary

  • FilterOptions.AfterApply now strings.TrimSpacees each Include / Exclude entry before validation, so multi-value env vars like PISTA_INCLUDE="user*, posts" (kong parses to ["user*", " posts"]) no longer silently fail to match.
  • Added TestFilterOptions_AfterApply_TrimsWhitespace covering spaces, tabs, and newlines on both fields.
  • Added a 1.10.5 entry to CHANGELOG.md.

Test plan

  • go test ./... (filter unit tests)
  • make vet
  • make lint

winebarrel and others added 2 commits May 22, 2026 15:24
PISTA_INCLUDE/PISTA_EXCLUDE values are normalized in FilterOptions.AfterApply
so leading/trailing whitespace around each pattern is stripped.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 22, 2026 06:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves CLI filter reliability by trimming leading/trailing whitespace from --include / --exclude patterns during FilterOptions.AfterApply, preventing common env-var multi-value parsing artifacts (e.g., " posts" entries) from silently failing to match object names.

Changes:

  • Trim whitespace on each FilterOptions.Include / Exclude entry before pattern validation.
  • Add a unit test covering trimming of spaces, tabs, and newlines for both include/exclude.
  • Document the behavior change in CHANGELOG.md as 1.10.5.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
options.go Trims Include/Exclude patterns via strings.TrimSpace before validating patterns.
filter_test.go Adds coverage ensuring AfterApply normalizes whitespace in include/exclude slices.
CHANGELOG.md Adds release note describing why trimming is necessary and how it affects matching/validation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.95%. Comparing base (f373430) to head (2da6bf1).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #238   +/-   ##
=======================================
  Coverage   91.94%   91.95%           
=======================================
  Files          50       50           
  Lines        5425     5429    +4     
=======================================
+ Hits         4988     4992    +4     
  Misses        230      230           
  Partials      207      207           
Flag Coverage Δ
pg15 91.91% <100.00%> (+<0.01%) ⬆️
pg16 91.91% <100.00%> (+<0.01%) ⬆️
pg17 91.91% <100.00%> (+<0.01%) ⬆️
pg18 91.95% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@winebarrel winebarrel merged commit 8e6803b into main May 22, 2026
11 checks passed
@winebarrel winebarrel deleted the trim-filter-patterns branch May 22, 2026 06:28
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.

2 participants