Skip to content

Fix file: dependency context resolution mismatch in rush-resolver-cache-plugin (pnpm v9/v10)#5802

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-file-protocol-error
Draft

Fix file: dependency context resolution mismatch in rush-resolver-cache-plugin (pnpm v9/v10)#5802
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-file-protocol-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 11, 2026

Bug Fix

resolveDependencyKey() handled file: specifiers differently from package context key generation, producing non-matching .pnpm paths (missing name@ prefix + different hash input). This caused createContextSerializer to fail context lookups with Missing context and emit incomplete resolver cache entries for file: dependencies.

  • What was the bug?

    file: dependencies from importer specifiers were resolved directly from raw file: strings, while package contexts were keyed from canonical dependency keys (name@file:... in v9/v10 lockfile format). The mismatch broke contexts.get(contextRoot).

  • How did you fix it?

    Updated the file: branch in resolveDependencyKey() to follow the same canonical-key path as other specifiers:

    • Use packageKeys passthrough when the exact key exists.
    • Otherwise build the canonical key via helpers.buildDependencyKey(key, specifier).
    • Resolve path from that canonical key so dep-path filename generation and hashing align with package context generation.
    } else if (specifier.startsWith('file:')) {
      const resolvedKey: string = packageKeys?.has(specifier)
        ? specifier
        : helpers.buildDependencyKey(key, specifier);
      return getDescriptionFileRootFromKey(lockfileFolder, resolvedKey, helpers.depPathToFilename, key);
    }
  • Testing

    Added targeted regression coverage in helpers.test.ts for:

    • pnpm v9/v10-style file: specifiers with peer suffixes using canonical key shape
    • pnpm v8 compatibility path generation for file: specifiers
    • packageKeys passthrough behavior when file: key already exists

Copilot AI changed the title Fix file: dependency context resolution mismatch in rush-resolver-cache-plugin (pnpm v9/v10) refactor(rush-resolver-cache-plugin): extract repeated specifier strings into variables in tests May 11, 2026
Copilot AI requested a review from bmiddha May 11, 2026 08:07
Copilot stopped work on behalf of bmiddha due to an error May 12, 2026 01:34
@bmiddha bmiddha changed the title refactor(rush-resolver-cache-plugin): extract repeated specifier strings into variables in tests Fix file: dependency context resolution mismatch in rush-resolver-cache-plugin (pnpm v9/v10) May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs triage

Development

Successfully merging this pull request may close these issues.

2 participants