Skip to content

_rel() raises when the bundle root is a symlink: test_titleless_stem_match fails on macOS #85

Description

@RichardHightower

Summary

_rel() in scripts/pkc_search.py:141 calls path.relative_to(bundle) without resolving bundle. The rg path supplies resolved paths, so on a symlinked root relative_to() raises ValueError and the search crashes.

rel = "/" + path.relative_to(bundle).as_posix()   # line 141, no resolve, no guard

Compare _filter_rg_hits() at line 52, which already resolves the root once (bundle_root = bundle.resolve(), line 54). Line 141 was missed.

Reproduce

python3 tests/test_pkc.py on macOS, where /var is a symlink to /private/var:

ERROR: test_titleless_stem_match_is_invisible_on_every_engine
  (__main__.TestRipgrepAccelerator)
ValueError: '/private/var/folders/tm/.../tmpz121mui2/features/other.md'
  is not in the subpath of '/var/folders/tm/.../tmpz121mui2'

It fails on clean main today: 111 tests run, 1 error. Linux CI has no /var symlink, so CI is green and the defect shipped.

Scope

Any symlinked root reproduces it, not only macOS: a symlinked home or checkout, a Docker bind mount, /tmp on macOS.

research-knowledge-capture#35 is the same defect in rkc_search.py, where the except ValueError branch swallows it and returns a wrong absolute path instead of raising. The two repos should get the same fix.

Suggested fix

Resolve both sides in _rel(), the way _filter_rg_hits() already does.

Found while adding the workflow parse gate in #84.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions