Skip to content

Visual Studio: DefaultVSCredentialServiceProvider hardcodes nonInteractive: false — interactivity posture heads-up (server-mode handling still lives in NuGet.Console) #15092

Open

Description

@alencheung

Summary

On dev (14d4623588), src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/DefaultVSCredentialServiceProvider.cs constructs the credential service with a constant:

var credentialService = new CredentialService(
    new AsyncLazy<IEnumerable<ICredentialProvider>>(() => ...),
    nonInteractive: false,

Before NuGet/NuGet.Client#7676 this was derived from the VS shell mode — nonInteractive = IsInServerModeAsync(...), with the removed comment "can only interact when VS is not in server mode". NuGet/NuGet.Client#7676 removed the derivation to eliminate the UI-thread switch that deadlocked credential-service initialization (the AsyncLazy conversion in the same area completed that cleanup), and states the rationale: VS's Nexus server mode was removed, VSSM_Server can no longer be returned, the branch was unreachable in supported modes, so the constant preserves the effective value.

Two residual observations, offered as a heads-up rather than a bug:

  1. The codebase still carries live server-mode handling: NuGet.Console/OutputConsole/OutputConsoleProvider.cs still consults IsInServerModeAsync for the cached build-output console. If any VS mode, embedded host, or future automation surface ever sets VSSM_Server again, the credential service will now be constructed interactive in exactly the state where the product's own history says auth must be non-interactive (Auth on server must be non-interactive. Auth on client should be interactive. NuGet.Client#3435, fixing Auth in Visual Studio should not always be interactive #9659): "Auth on server must be non-interactive. Auth on client should be interactive."). Nothing would surface that drift: the flag is a literal, so no assertion, log line, or test fires.

  2. The interactivity decision is now encoded at the construction site, disconnected from the shell state it used to mirror — the coupling between "server mode exists" and "credential service is non-interactive" lives only in the PR description, not in the code.

Repro

Code-level; no runtime needed:

$ git show 14240937a -- src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/DefaultVSCredentialServiceProvider.cs
-            // can only interact when VS is not in server mode.
-            bool nonInteractive = await VisualStudioContextHelper.IsInServerModeAsync(CancellationToken.None);
             var credentialService = new CredentialService(
-                nonInteractive: nonInteractive,
+                nonInteractive: false,

and the surviving consumer of the same helper:

$ grep -rn "IsInServerModeAsync" src/NuGet.Console/
src/NuGet.Console/OutputConsole/OutputConsoleProvider.cs:  ... server mode still a handled state here ...

Suggested fix

If server mode is truly unreachable, a derivation without a UI-thread switch keeps the posture self-maintaining and removes the literal:

  • capture the shell mode once at initialization, off the hot path (e.g. VisualStudioContextHelper caching the value from a single background-thread switch before any credential path needs it), and derive nonInteractive from that snapshot; or
  • keep the constant, but emit a one-time assertion/telemetry event when server mode IS observed in a credential-service construction path, so posture drift becomes observable instead of silent.

Impact framing

Dev-branch observation only (no tag or release branch carries these commits as of 2026-09-21; newest tag v11.0.0 predates the window). Not a vulnerability report — under the stated rationale the constant is behavior-preserving today; the concern is purely that a documented interactivity posture now rests on an external fact (server-mode unreachability) that the code neither checks nor asserts, while a sibling component still treats server mode as a live state.

Activity

  1. nkolev92 commented on Sep 21, 2026

    @nkolev92
    Member

    We should remove all code that references VisualStudioContextHelper.IsInServerModeAsync and that method.

    VS is always interactive.

  2. added
    Priority:3Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog.
    Type:Engineeringproduct/infrastructure work/not a customer bug/feature/DCR
    on Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority:3Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog.Product:VS.ClientType:Engineeringproduct/infrastructure work/not a customer bug/feature/DCR

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions