Skip to content

fix(node-dev): report search matches relative to custom_nodes/ so read can open them - #2930

Closed
wangzhengzhuo05 wants to merge 1 commit into
artokun:mainfrom
wangzhengzhuo05:fix/node-pack-search-read-path
Closed

wangzhengzhuo05 wants to merge 1 commit into
artokun:mainfrom
wangzhengzhuo05:fix/node-pack-search-read-path

Conversation

@wangzhengzhuo05

Copy link
Copy Markdown
Contributor

What

node_pack action search reported every match path relative to the search's own path
walk root, while read / write / list_files resolve their path argument against the
custom_nodes/ base root. So a path returned by search could not be fed back into
read: it failed with NODE_DEV_ERROR: File not found under custom_nodes/: "<path>".

Reproduction from the issue: search with path set to a pack folder returns
web/js/<file>.js, and the matching read looks for custom_nodes/web/js/<file>.js.
The default path: "." happened to work only because the walk root is the base root.

How

  • In searchNodePacks, compute the base root and the walk root's offset from it:

    const baseRoot = customNodesRoot(resolvedBase);
    const relPrefix = relative(baseRoot, searchDir).split(/[\\/]/).join("/");
  • Pass relPrefix into both engines and prepend it to the reported file:

    • searchBuiltin: file: relPrefix ? ${relPrefix}/${rel} : rel
    • searchWithRipgrep: file: relPrefix ? ${relPrefix}/${m[1]} : m[1]
  • Behavior with the default path: "." is unchanged (the prefix is empty), and the
    path/glob filtering still matches against the search-dir-relative path so glob
    semantics are untouched.

Tests

  • New builtin regression test: create Pack/nodes.py, search { query: "FooNode", path: "Pack" },
    assert the reported file is Pack/nodes.py, then feed that exact string to readNodeFile
    and assert the content comes back — the full round trip from the issue.
  • New ripgrep-path regression test asserting the same root-relative result through the
    mocked ripgrep seam.
  • npx vitest run src/__tests__/services/node-dev.test.ts → 84 passed
  • npx tsc --noEmit → clean

Mutation check

Reverting only the two file: expressions to their pre-fix form makes both new tests fail
(2 failed, 82 skipped); restoring the fix makes them pass. The new tests genuinely guard
the change.

Fixes #2921

…d can open them

search's own `path` argument is the walk root, so matches were returned relative
to it (a pack folder when path was a pack). read resolves against the custom_nodes/
base, so a search result could not be fed to read and failed with
"File not found under custom_nodes/". Prefix reported paths with the walk root's
offset from the base root; the default path "." is unchanged.

Fixes artokun#2921
Copilot AI balanced review requested due to automatic review settings September 10, 2026 06:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@wangzhengzhuo05

Copy link
Copy Markdown
Contributor Author

Closing this to keep the tracker clean \u2014 it has been sitting without review for several days. This is no reflection on the change itself: the fix and its local verification still stand. If the issue is still present and you would like the patch revisited, say the word and I will rebase it onto current main and re-open. Thanks for your time.

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.

node_pack read cannot open a file returned by node_pack search

2 participants