Skip to content

[MTP Core Analysis] Pipe connection failure mentions the wrong environment variable #8425

@Evangelink

Description

@Evangelink

Summary

When the test-host controller named-pipe environment variable is missing, the exception message points to the base environment-variable name instead of the per-PID key the code actually tried to read.

Evidence

  • src/Platform/Microsoft.Testing.Platform/Hosts/TestHostBuilder.Utilities.cs:40-41
    string pipeEnvironmentVariable = $"{EnvironmentVariableConstants.TESTINGPLATFORM_TESTHOSTCONTROLLER_PIPENAME}_{testHostControllerInfo.GetTestHostControllerPID()}";
    string pipeName = environment.GetEnvironmentVariable(pipeEnvironmentVariable) ?? throw new InvalidOperationException($"Unexpected null pipe name from environment variable '{EnvironmentVariableConstants.TESTINGPLATFORM_TESTHOSTCONTROLLER_PIPENAME}'");
  • src/Platform/Microsoft.Testing.Platform/Hosts/TestHostControllersTestHost.cs:138
    writes the per-process key:
    { $"{EnvironmentVariableConstants.TESTINGPLATFORM_TESTHOSTCONTROLLER_PIPENAME}_{currentPid}", testHostControllerIpc.PipeName.Name },

Why this is a real issue

The read path looks up TESTINGPLATFORM_TESTHOSTCONTROLLER_PIPENAME_<pid>, but if that lookup fails the thrown exception says the missing variable was TESTINGPLATFORM_TESTHOSTCONTROLLER_PIPENAME.

That sends anyone debugging controller startup to the wrong environment variable name, even though the failure is actually on the PID-qualified key. This is a concrete diagnostics bug in the exact message users and maintainers see when pipe setup goes wrong.

Suggested resolution

Include pipeEnvironmentVariable in the exception message so the error reports the exact missing key. A focused unit test for the failure message would keep the diagnostic accurate.

Related issues

  • None found in the current open-issues list.

Metadata

Metadata

Labels

Area: MTPBelongs to the Microsoft.Testing.Platform core libraryautomated-analysis

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions