Skip to content

fix(ci): use path segment boundary matching to prevent prefix collisions#135

Merged
bedatty merged 3 commits intodevelopfrom
fix/filter-prefix-collision
Mar 12, 2026
Merged

fix(ci): use path segment boundary matching to prevent prefix collisions#135
bedatty merged 3 commits intodevelopfrom
fix/filter-prefix-collision

Conversation

@bedatty
Copy link
Contributor

@bedatty bedatty commented Mar 11, 2026

Lerian

GitHub Actions Shared Workflows


Description

Fixes a prefix collision bug in the changed-paths composite action's filter matching logic.

Bug: The pattern [[ "$DIR" == "$FILTER"* ]] matches on string prefix, not path segment boundary. This means init/casdoor incorrectly matches init/casdoor-migrations, causing the wrong filter to be applied and the break to skip the correct filter.

Fix: Replace with path-segment-aware matching:

[[ "$DIR" == "$FILTER" ]] || [[ "$DIR" == "$FILTER"/* ]]

Now init/casdoor only matches init/casdoor or init/casdoor/..., never init/casdoor-migrations.

Type of Change

  • feat: New workflow or new input/output/step in an existing workflow
  • fix: Bug fix in a workflow (incorrect behavior, broken step, wrong condition)
  • perf: Performance improvement (e.g. caching, parallelism, reduced steps)
  • refactor: Internal restructuring with no behavior change
  • docs: Documentation only (README, docs/, inline comments)
  • ci: Changes to self-CI (workflows under .github/workflows/ that run on this repo)
  • chore: Dependency bumps, config updates, maintenance
  • test: Adding or updating tests
  • BREAKING CHANGE: Callers must update their configuration after this PR

Breaking Changes

None. Callers that had overlapping prefixes and worked around it by ordering filter_paths longest-first will continue to work. Callers that were silently affected by the collision will now match correctly.

Testing

  • YAML syntax validated locally
  • Triggered a real workflow run on a caller repository using @develop or the beta tag
  • Verified all existing inputs still work with default values
  • Confirmed no secrets or tokens are printed in logs
  • Checked that unrelated workflows are not affected

Caller repo / workflow run: To be validated on plugin-auth with init/casdoor and init/casdoor-migrations filters.

Related Issues

Related to #131 (discovered during tag comparison fix investigation).

Summary by CodeRabbit

  • Bug Fixes
    • Improved directory filtering: trailing slashes are trimmed and matching now covers exact directories and their nested subdirectories (rather than relying on simple prefix checks), preventing incorrect exclusions and ensuring filtered results are produced correctly.

@bedatty bedatty requested a review from a team as a code owner March 11, 2026 21:26
@coderabbitai
Copy link

coderabbitai bot commented Mar 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: ASSERTIVE

Plan: Pro

Run ID: bfd32c60-0a98-4505-ada7-0616ac2ab01e

📥 Commits

Reviewing files that changed from the base of the PR and between 6de5b73 and fa66bd1.

📒 Files selected for processing (1)
  • src/config/changed-paths/action.yml

Walkthrough

Trims trailing slashes from each FILTER and changes matching so a directory passes when it equals the normalized FILTER or when it is under that FILTER (DIR == FILTER or DIR starts with FILTER/), replacing the previous prefix-only check.

Changes

Cohort / File(s) Summary
Filter Directory Matching
src/config/changed-paths/action.yml
Normalize filters by removing trailing slashes and update condition to match when DIR == FILTER OR DIR starts with FILTER/. Adjusts inclusion logic for directory filters. Breaking change: shifts behavior from naive prefix-match to normalized exact-or-subpath match.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing prefix collision bugs in path matching logic by using path segment boundary matching instead of string prefix matching.
Description check ✅ Passed The description comprehensively covers the bug, fix, type of change, breaking changes, testing status, and related issues. Most required template sections are completed with substantive content.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/filter-prefix-collision

Comment @coderabbitai help to get the list of available commands and usage tips.

@bedatty bedatty self-assigned this Mar 11, 2026
coderabbitai[bot]
coderabbitai bot previously requested changes Mar 11, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/config/changed-paths/action.yml`:
- Around line 131-132: The FILTER trailing-slash normalization currently strips
only one slash using "${FILTER%/}", which fails for inputs like
"init/casdoor//"; update the normalization before the comparison used in the if
condition (the block referencing DIR and FILTER and the test if [[ "$DIR" ==
"$FILTER" ]] || [[ "$DIR" == "$FILTER"/* ]]) to remove all trailing slashes from
FILTER (e.g. loop while FILTER ends with '/' repeatedly strip the trailing
slash) so FILTER becomes a canonical no-trailing-slash path before matching.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 56e1826e-e1c0-4e83-820c-28350040910b

📥 Commits

Reviewing files that changed from the base of the PR and between aa8059e and 6de5b73.

📒 Files selected for processing (1)
  • src/config/changed-paths/action.yml

@bedatty bedatty dismissed coderabbitai[bot]’s stale review March 11, 2026 21:35

All comments addressed.

@bedatty bedatty merged commit 8ab1bb0 into develop Mar 12, 2026
1 check passed
@github-actions github-actions bot deleted the fix/filter-prefix-collision branch March 12, 2026 00:04
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.

1 participant