Skip to content

fix: Change 3 to 4 in npm_package_store prefix len#2864

Open
oscar-meroton wants to merge 1 commit into
aspect-build:mainfrom
oscar-meroton:fix-package-store-prefix-len
Open

fix: Change 3 to 4 in npm_package_store prefix len#2864
oscar-meroton wants to merge 1 commit into
aspect-build:mainfrom
oscar-meroton:fix-package-store-prefix-len

Conversation

@oscar-meroton

Copy link
Copy Markdown

When calculating the package store prefix truncation with external modules (i.e. a repo name is included in the path), an extra slash after the repo name was unaccounted for, resulting in incorrect symlinks (and subsequently ERR_MODULE_NOT_FOUND error during builds).

Below is an example of the logic used to calculate the truncation length:

# ../[com_github_example_repo+]/[example_package]/[node_modules/.aspect_rules_js/]foo@1.2.3/node_modules/bar
#    |        repo name       | |  package name | |         store prefix         |

path = "../com_github_example_repo+/example_package/node_modules/.aspect_rules_js/foo@1.2.3/node_modules/bar"
truncate_length = len(repo_name) + len(package_name) + len(store_prefix) + 3 # = 72
truncated_path = path[truncate_length:] # = "s/foo@1.2.3/node_modules/bar"

The extra s in the beginning of truncated_path should not be there and is solved by changing the + 3 to a + 4.

When calculating the length of the package store prefix
for truncation, an extra slash after the repo name was
unaccounted for, resulting in incorrect symlinks.

Co-authored-by: Fredrik Medley <fredrik@meroton.com>
@jbedard

jbedard commented Jun 3, 2026

Copy link
Copy Markdown
Member

@oscar-meroton sorry I didn't see this till now. How can we reproduce this in a test?

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