Skip to content

Await Workspace Trust transition completion in setUrisTrust() - #328626

Open
zainnadeem786 wants to merge 1 commit into
microsoft:mainfrom
zainnadeem786:fix/workspace-trust-transition-await
Open

Await Workspace Trust transition completion in setUrisTrust()#328626
zainnadeem786 wants to merge 1 commit into
microsoft:mainfrom
zainnadeem786:fix/workspace-trust-transition-await

Conversation

@zainnadeem786

Copy link
Copy Markdown

Fixes #328625

Summary

Ensure WorkspaceTrustManagementService.setUrisTrust() does not resolve until the underlying Workspace Trust transition has completed.

Root Cause

setUrisTrust() invoked the asynchronous doSetUrisTrust(...) operation without awaiting its returned promise.

As a result, callers awaiting setUrisTrust() or setWorkspaceTrust() could resume before asynchronous Workspace Trust transition participants completed and before onDidChangeTrust was emitted.

Change

Await the existing doSetUrisTrust(...) promise inside setUrisTrust().

This ensures that the public promise resolves only after the complete Workspace Trust transition has finished.

Regression Test

Added a focused regression test that registers a controlled asynchronous Workspace Trust transition participant and verifies that setWorkspaceTrust() remains unresolved until:

  • the transition participant completes; and
  • the onDidChangeTrust event fires.

The test fails on the previous implementation and passes after the fix.

Validation

  • npm run compile
  • .\scripts\test.bat --grep "setWorkspaceTrust waits for trust transition participants before resolving"
    • 1 passing
  • .\scripts\test.bat --grep "Workspace Trust"
    • 10 passing
  • git diff --check

Copilot AI review requested due to automatic review settings August 2, 2026 19:15

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.

🟢 Ready to approve

The minimal fix addresses the premature resolution and is covered by a targeted regression test.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

Ensures Workspace Trust APIs resolve only after asynchronous trust transitions and notifications complete.

Changes:

  • Awaits doSetUrisTrust().
  • Adds focused regression coverage for participant and event ordering.
File summaries
File Description
workspaceTrust.ts Awaits the complete trust transition.
workspaceTrust.test.ts Verifies correct asynchronous completion ordering.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

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.

WorkspaceTrustManagementService.setUrisTrust() resolves before asynchronous Workspace Trust transition completes

3 participants