Skip to content

Fix false positive in isAbsPathOverlapping path boundary check#14426

Open
soya111 wants to merge 1 commit intografana:mainfrom
soya111:fix/is-abs-path-overlapping-prefix-boundary
Open

Fix false positive in isAbsPathOverlapping path boundary check#14426
soya111 wants to merge 1 commit intografana:mainfrom
soya111:fix/is-abs-path-overlapping-prefix-boundary

Conversation

@soya111
Copy link

@soya111 soya111 commented Feb 19, 2026

What this PR does

Fixes a false positive in isAbsPathOverlapping where strings.HasPrefix does not respect path segment boundaries.

For example, /data/tsdb and /data/tsdb-compactor/cache are sibling directories that should not overlap, but strings.HasPrefix("/data/tsdb-compactor/cache", "/data/tsdb") returns true because it operates on raw strings without considering / boundaries.

The fix appends "/" before comparing, so only true parent/child relationships are detected as overlapping.

Which issue(s) this PR fixes or relates to

N/A — discovered while configuring component storage paths.

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • about-versioning.md updated with experimental features.

Note

Low Risk
Small, well-tested change to config sanity checking that only affects startup validation for filesystem paths and reduces false positives.

Overview
Fixes a config validation bug where filesystem path overlap detection could incorrectly flag sibling directories as overlapping when one path was only a string prefix of the other.

isAbsPathOverlapping now treats / as overlapping with any absolute path and uses a HasPrefix(path, other+"/") boundary check to only detect true parent/child directory relationships; tests were extended with regression cases and the fix is noted in CHANGELOG.md.

Written by Cursor Bugbot for commit 9dd896c. This will update automatically on new commits. Configure here.

Copilot AI review requested due to automatic review settings February 19, 2026 14:53
@soya111 soya111 requested a review from a team as a code owner February 19, 2026 14:53
@CLAassistant
Copy link

CLAassistant commented Feb 19, 2026

CLA assistant check
All committers have signed the CLA.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before Autofix could start.

Copy link
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

Fixes a false positive in isAbsPathOverlapping by making the overlap check respect path segment boundaries (so sibling directories that share a string prefix aren’t treated as overlapping).

Changes:

  • Update isAbsPathOverlapping to require a separator boundary when checking parent/child relationships.
  • Add regression tests covering “string prefix but not ancestor” cases.
  • Add a changelog entry documenting the bugfix.

Reviewed changes

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

File Description
pkg/mimir/mimir.go Adjusts overlap detection logic to avoid prefix-based false positives.
pkg/mimir/mimir_test.go Adds regression test cases for sibling vs ancestor path relationships.
CHANGELOG.md Records the bugfix in the changelog.
Comments suppressed due to low confidence (1)

pkg/mimir/mimir.go:647

  • isAbsPathOverlapping uses filepath.Split/filepath.Abs (OS-specific separators), but the new boundary check hard-codes "/". On Windows paths use \, so this will fail to detect overlaps (false negatives). Consider appending string(filepath.Separator) (or string(os.PathSeparator)) instead of "/" and, if needed, normalize inputs with filepath.Clean to avoid doubled separators.
	// We append "/" to ensure we match on path segment boundaries and avoid false positives
	// like "/data/tsdb" matching "/data/tsdb-compactor/cache".
	return strings.HasPrefix(firstAbsPath, secondAbsPath+"/") || strings.HasPrefix(secondAbsPath, firstAbsPath+"/")

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

strings.HasPrefix without a trailing "/" causes false positives when
one path is a string prefix of another but not a path ancestor
(e.g. "/data/tsdb" vs "/data/tsdb-compactor/cache"). Append "/"
before comparing to enforce path segment boundaries.
@soya111 soya111 force-pushed the fix/is-abs-path-overlapping-prefix-boundary branch from 560d375 to 9dd896c Compare February 19, 2026 15:16
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

Comments