Skip to content

Fix stale Pylance resolution in cached builds - #8588

Merged
StellaHuang95 merged 3 commits into
microsoft:mainfrom
StellaHuang95:fix/pylance-cache-refresh
Jul 23, 2026
Merged

Fix stale Pylance resolution in cached builds#8588
StellaHuang95 merged 3 commits into
microsoft:mainfrom
StellaHuang95:fix/pylance-cache-refresh

Conversation

@StellaHuang95

@StellaHuang95 StellaHuang95 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Issue

PTVS nightly builds have remained on Pylance 2025.12.104 even though newer stable and prerelease versions were published and available in the msft_consumption feed. For example, build 14744946 requested latest/preview but selected and installed 2025.12.104.

The behavior started after the caching changes in #8418. The cache landed on February 26, 2026; 2026.1.100 reached the feed on February 27, but the February 28 nightly and every later nightly continued selecting 2025.12.104.

Root cause

  • The restore task sets npm_config_prefer_offline=true to accelerate installs. That also affected npm view, causing it to bypass staleness checks and read an old cached package-version catalog.
  • Azure pipeline caches are immutable, so the catalog containing 2025.12.104 continued to be restored even after newer versions reached the feed.
  • Broad restore keys omitted the requested stable/preview channel, allowing partial restores across channels.
  • Exact versions such as 2026.3.1 were inserted into Cache@2 keys without quotes. Cache@2 interpreted the dotted value as a file path and failed with File not found: 2026.3.1 before package restoration began. The same issue applied to explicit debugpy versions.

The pyrx publication path itself is healthy: newer versions are present in msft_consumption, and the release pipeline successfully queued PTVS with the exact released version.

Fix

  • Force npm view to refresh registry metadata when resolving latest, while retaining the npm cache for package downloads.
  • Quote Pylance and debugpy version parameters in Cache@2 keys so dotted versions are treated as literal strings.
  • Place the Pylance version and release channel before the mutable package.json segment and keep partial cache restores within the same requested channel.

With the current feed contents, the corrected lookup resolves stable 2026.3.1 and preview 2026.2.109. Future releases will be discovered from the feed rather than from stale cached metadata.

Validation

  • Parsed the updated PowerShell and YAML successfully.
  • Ran latest-version discovery with npm_config_prefer_offline=true; the command-level freshness override resolved stable 2026.3.1 and preview 2026.2.109.
  • Confirmed the branch contains only the two intended PTVS files.

Follow-up: Node 24 requirement

PR build 14750001 confirmed that fresh resolution works: it selected and installed Pylance 2026.3.1. The restore task then failed because the agent supplied Node 12.22.12, while current Pylance packages declare engines.node >=24. npm wrote the unsupported-engine warning to stderr, and PowerShell@1 treated that output as a task error despite npm exiting successfully.

The shared restore template now selects Node 24.x before invoking npm. This satisfies the current stable and preview Pylance packages instead of suppressing a genuine compatibility warning.
npm 11 also exposed the repository's obsolete always-auth=true project setting. npm 11 reports it as an unknown configuration on stderr, which caused the same PowerShell task failure after the Node upgrade. The setting has been removed; npmAuthenticate@0 continues to inject registry-scoped credentials.
PR build 14750412 validates the complete fix: Node 24 setup succeeded, Restore packages completed successfully, Pylance 2026.3.1 was installed, and debugpy 1.8.21 was installed without npm configuration or engine warnings.

Refresh registry metadata when resolving latest Pylance versions, while preserving cached package downloads. Quote and scope dynamic cache key segments so explicit dotted versions work and stable/preview cache fallbacks do not cross channels.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 42f01b56-f94e-4760-8e1d-d0893ff82b26
@StellaHuang95
StellaHuang95 requested a review from a team as a code owner July 23, 2026 19:11
Copilot AI review requested due to automatic review settings July 23, 2026 19:11
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@heejaechang

Copy link
Copy Markdown

🔒 Automated review in progress — @heejaechang is auto-reviewing this PR.

@StellaHuang95

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request updates the Azure Pipelines restore flow to prevent stale Pylance “latest/preview” resolution when npm caches are restored between builds, while keeping the performance benefits of cached installs.

Changes:

  • Adjust Cache@2 keys/restore keys so node/npm caches are segmented by Pylance version + release channel and dotted version strings are treated as literals.
  • Force npm view (used only for resolving latest) to refresh registry metadata even when CI sets npm_config_prefer_offline=true.
  • Quote debugpy version in the PyPI wheels cache key to avoid Cache@2 interpreting dotted versions as file paths.
Show a summary per file
File Description
Build/templates/restore_packages.yml Refines cache keys to avoid cross-channel restores and to correctly treat version tokens as literals.
Build/PreBuild.ps1 Ensures npm view refreshes registry metadata when resolving latest under offline-preferring CI settings.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Low

@heejaechang heejaechang 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.

Approved via Review Center.

Pylance 2026.3.1 and current previews require Node 24. Select a compatible Node runtime before the shared package restore so npm does not emit an unsupported-engine error under the agent default Node 12.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 42f01b56-f94e-4760-8e1d-d0893ff82b26
Copilot AI review requested due to automatic review settings July 23, 2026 19:30
@StellaHuang95

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Low

@heejaechang heejaechang 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.

Approved via Review Center.

npm 11 no longer recognizes always-auth and writes a warning to stderr for every command. npmAuthenticate continues to provide registry-scoped credentials, so remove the unsupported project setting to keep the restore task error-free under Node 24.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 42f01b56-f94e-4760-8e1d-d0893ff82b26
Copilot AI review requested due to automatic review settings July 23, 2026 19:46
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Low

@StellaHuang95

Copy link
Copy Markdown
Contributor Author

/azp run

@heejaechang heejaechang 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.

Approved via Review Center.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@StellaHuang95
StellaHuang95 merged commit 53851ff into microsoft:main Jul 23, 2026
8 checks passed
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.

4 participants