Skip to content

fix: resolve dashboard token auth, health seeding, and MTP dotnet test runner - #689

Merged
jongio merged 7 commits into
mainfrom
fix/dashboard-health-and-dotnet-test
Nov 12, 2026
Merged

jongio merged 7 commits into
mainfrom
fix/dashboard-health-and-dotnet-test

Conversation

@jongio

@jongio jongio commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Pull Request

Thank you for your contribution!

Description

Fix dashboard client/server lifecycle handling, standalone azd app health probes, Windows environment parsing, and .NET Microsoft.Testing.Platform test execution:

  • Dashboard client & server: Read the owner-only ~/.azd/azd-app/<hash>/session-token and per-project port file in dashboard.NewClient instead of calling the removed /api/session-token endpoint; bind dashboard TCP listeners synchronously (net.Listen + Serve) before publishing port/token discovery files or marking the server started; preserve azure.yaml fallback in azd app info --json when dashboard RPCs fail; avoid falling back to stale port files in waitForDashboardURL when a dashboard.Server instance is present.
  • Health checks & registry scoping: Seed live service PIDs, ports, statuses, and build/task exit codes from the running dashboard in azd app health (including --stream refreshes); populate HTTP probe URLs from healthcheck.path in azure.yaml; skip registry updates for unregistered services without warnings; scope orchestrator registry lookups to projectDir instead of os.Getwd().
  • Environment & .NET testing: Ignore empty-key environment entries (such as Windows hidden per-drive =C:=... working-directory entries) in service and serviceinfo; detect Microsoft.Testing.Platform in DotnetTestRunner (omitting VSTest-only --logger/--collect flags and parsing succeeded:/total: summary lines).

Validation

  • gofmt -w -s . & go vet ./... (cli/) — passed
  • go test -short ./src/cmd/app/commands/... ./src/internal/dashboard/... ./src/internal/healthcheck/... ./src/internal/service/... ./src/internal/serviceinfo/... ./src/internal/testing/... ./src/internal/docsgate/... — passed
  • go run ./src/cmd/app metadata | go run ./src/cmd/docsgate --repo-root .. --changed-files <changed-files> — passed (Docs gate passed. 35 command(s) documented.)

Related issues: None.

Checklist

  • All tests pass
  • Documentation updated
  • CHANGELOG.md updated
  • Follows code style guidelines

…t runner

- Read owner-only session-token and port files in dashboard.NewClient and preserve JSON fallback in azd app info
- Bind dashboard listeners synchronously before writing port/token files or marking the server started, and avoid stale port-file fallback in waitForDashboardURL
- Seed live service state and build/task exit codes from the running dashboard in azd app health, honor healthcheck.path in azure.yaml, and skip unregistered-service registry warnings
- Scope service orchestration registry lookups to projectDir instead of os.Getwd()
- Skip empty-key Windows drive-CWD environment entries (=C:=...) during environment resolution
- Support Microsoft.Testing.Platform runner options and summary parsing in DotnetTestRunner

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Website Preview

Your PR preview was available here.

Preview has been cleaned up as the PR was closed.

github-actions Bot added a commit that referenced this pull request Nov 12, 2026
@jongio
jongio requested a balanced review from Copilot November 12, 2026 03:49
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Test This PR

A preview build (0.21.1-pr689) is ready for testing!

🌐 Website Preview

Live Preview: https://jongio.github.io/azd-app/pr/689/

One-Line Install (Recommended)

PowerShell (Windows):

iex "& { $(irm https://raw.githubusercontent.com/jongio/azd-app/main/cli/scripts/install-pr.ps1) } -PrNumber 689 -Version 0.21.1-pr689"

Bash (macOS/Linux):

curl -fsSL https://raw.githubusercontent.com/jongio/azd-app/main/cli/scripts/install-pr.sh | bash -s 689 0.21.1-pr689

Uninstall

When you're done testing:

PowerShell (Windows):

iex "& { $(irm https://raw.githubusercontent.com/jongio/azd-app/main/cli/scripts/uninstall-pr.ps1) } -PrNumber 689"

Bash (macOS/Linux):

curl -fsSL https://raw.githubusercontent.com/jongio/azd-app/main/cli/scripts/uninstall-pr.sh | bash -s 689

Build Info:

What to Test:
Please review the PR description and test the changes described there.

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.

🟡 Changes recommended

Unresolved health-status and exit-code handling errors can misreport services, while .NET runner configuration and argument bugs can bypass test filters or break test and coverage execution.

6 open issues
What changed in this PR

This PR improves reliability across azd-app’s dashboard, standalone health checks, environment handling, and .NET test execution.

Changes:

  • Uses file-based dashboard authentication and binds listeners before publishing discovery state.
  • Seeds health checks from dashboard state, honors configured probe paths, and scopes service registries to the project.
  • Filters invalid Windows environment entries and adds Microsoft.Testing.Platform detection and summary parsing.
File Description
cli/​src/​internal/​testing/​dotnet_runner.go Adds MTP detection, coverage arguments, and summary parsing.
cli/​src/​internal/​testing/​dotnet_runner_test.go Tests MTP command construction and summary parsing.
cli/​src/​internal/​serviceinfo/​serviceinfo.go Rejects empty-key environment entries.
cli/​src/​internal/​serviceinfo/​environment_test.go Tests environment-entry parsing.
cli/​src/​internal/​service/​orchestrator.go Scopes orchestration and cleanup registries to the project.
cli/​src/​internal/​service/​environment.go Filters malformed and Windows hidden environment entries.
cli/​src/​internal/​service/​environment_test.go Tests environment parsing edge cases.
cli/​src/​internal/​healthcheck/​monitor.go Builds configured probe URLs and skips unregistered updates.
cli/​src/​internal/​healthcheck/​monitor_integration_test.go Tests probe paths and unregistered-service handling.
cli/​src/​internal/​dashboard/​server_port_mgmt.go Binds alternative ports before publishing discovery state.
cli/​src/​internal/​dashboard/​server_core.go Makes listener binding synchronous during startup.
cli/​src/​internal/​dashboard/​client.go Reads dashboard port and authentication token from files.
cli/​src/​internal/​dashboard/​client_test.go Tests file-based discovery and token requirements.
cli/​src/​cmd/​app/​commands/​run_orchestration.go Passes project scope and avoids stale dashboard-port fallback.
cli/​src/​cmd/​app/​commands/​run_orchestration_test.go Renames the not-started-server test to describe stale-port behavior.
cli/​src/​cmd/​app/​commands/​info.go Preserves configuration fallback when dashboard RPCs fail in JSON mode.
cli/​src/​cmd/​app/​commands/​health.go Seeds and refreshes local registry state from the dashboard.
cli/​src/​cmd/​app/​commands/​health_test.go Tests dashboard-derived registry seeding.
CHANGELOG.md Documents the fixes.

Review effort: Balanced

Comment thread cli/src/cmd/app/commands/health.go Resolved
Comment thread cli/src/cmd/app/commands/health.go Resolved
- Normalize stopped services back to "stopped" and round-trip rawStatus, exitCode, and endTime through ServicesService metadata so standalone health checks preserve terminal results
- Distinguish native .NET 10 global.json MTP (--project and direct extension args) from MSBuild TestingPlatformDotnetTestSupport (-- separator forwarding)
- Inspect only the selected first test project for MTP detection and follow .NET nearest-global.json resolution to the filesystem root

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jongio

jongio commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner Author
  • Review 5868841546 (concern:2ce14d8b702493c2): Fixed in db974c6 — preserved stopped/terminal statuses and exact exit codes across the ServicesService RPC round trip, and separated native .NET 10 MTP (--project) from MSBuild MTP (-- forwarding).
  • Review 5869244420 — Parse active MTP properties instead of raw XML substrings (concern:30d4e489029ef713, concern:1436971efce11ce9): Fixed in fb21eac — parsed active <PropertyGroup> XML elements with encoding/xml, used explicit 127.0.0.1 loopback in dashboard.newClientForPort, and started global.json discovery from r.projectDir.
  • Review 5869458175 — Port discovery trusts attacker-controlled shared-temp files (concern:451b0852ca883aee), global.json comments cause incorrect test-runner detection (concern:ea5dac5afdfd7a0e), and MTP detection ignores imported MSBuild properties (concern:c59de0be93d5d7c0, concern:18581243763de166): Fixed in ac8b4ba and f09b19b — stored the dashboard port file inside the owner-only 0o700 ~/.azd/azd-app/<hash>/ state directory (failing closed on persistence error), stripped JSONC comments/trailing commas when parsing global.json, and evaluated ancestor Directory.Build.props plus explicit <Import> files.
  • Review 5869724243 (concern:622bc36e9703d90b): Fixed in 1c46c85 — probed the exact Directory.Build.props filename via os.Stat so discovery follows filesystem case-sensitivity rules.
  • Review 5869955864 — Needs a closer look (concern:15ad267d58202049): Assessed on 1c46c85 (no code change needed) — conditioned MSBuild <PropertyGroup>/<Import>/property elements are intentionally skipped during static XML discovery to avoid false-positive -- forwarding when MSBuild expressions cannot be evaluated statically; healthcheck.path only populates default HTTP endpoint URLs when test is unset (type: none already sets test: ["NONE"]); and --stream refreshes active/stopped dashboard entries each tick while HealthChecker + updateRegistry probe live port/PID state directly if the dashboard exits.

github-actions Bot added a commit that referenced this pull request Nov 12, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Nov 12, 2026
@jongio
jongio requested a balanced review from Copilot November 12, 2026 04:37

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.

🟡 Changes recommended

The dashboard client can leak its session token to a separate IPv6 localhost listener, while configuration-discovery and XML-parsing flaws can select incompatible .NET test-runner arguments.

2 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Parse active MTP properties instead of raw XML substrings

cli/​src/​internal/​testing/​dotnet_runner.go:220

Raw substring matching treats commented-out MTP opt-ins as active and misses valid values with whitespace before true. This selects the wrong runner branch, sending MTP arguments to VSTest or unsupported VSTest flags to MTP. Read active XML property values (or evaluated MSBuild properties) and add regression cases for comments and whitespace.

6 resolved since last review

Review effort: Balanced

Comment thread cli/src/internal/dashboard/client.go Resolved
…overy

- Target explicit 127.0.0.1 loopback in dashboard.newClientForPort to match server listener binding
- Resolve global.json starting from DotnetTestRunner.projectDir to match dotnet CLI invocation CWD
- Parse active XML PropertyGroup elements for MTP opt-in properties, ignoring comments and trimming whitespace

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Nov 12, 2026
@jongio
jongio requested a balanced review from Copilot November 12, 2026 05:02

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.

🔵 Needs a closer look

Dashboard discovery can leak live authentication tokens to a local attacker, while .NET runner detection misclassifies valid configurations using imported MSBuild properties or commented global.json files.

No open issues 🎉

3 previously missed issues

In code that hasn't changed since last review

High severity Port discovery trusts attacker-controlled shared-temp files

cli/​src/​internal/​dashboard/​client.go:71

On systems with a shared temporary directory, another local user can observe the nonce-bearing port filename and recreate it with their own listener's port after shutdown; the next dashboard startup ignores the failed overwrite but still publishes its live token. This client then sends that token to the attacker-controlled listener, exposing authenticated dashboard access and allowing forged RPC responses. Store and read the port alongside the token in the owner-only project state directory, and fail closed if trusted discovery state cannot be published.

Medium severity global.json comments cause incorrect test-runner detection

cli/​src/​internal/​testing/​dotnet_runner.go:198

global.json supports JSON comments, but json.Unmarshal rejects them. A valid .NET 10 file with a comment and test.runner = Microsoft.Testing.Platform therefore returns false here; without a project-level override, buildTestCommand emits VSTest arguments (including a positional project) that the native MTP runner rejects. Parse the file with the SDK's comment support and add a commented-file regression case.

Medium severity MTP detection ignores imported MSBuild properties

cli/​src/​internal/​testing/​dotnet_runner.go:217

projectEnablesMTP only reads the selected project file, so an MSBuild-MTP project that enables TestingPlatformDotnetTestSupport in Directory.Build.props or an imported .props file is incorrectly classified as VSTest. dotnet test evaluates those imports and runs MTP, but this runner then emits VSTest coverage/logger options and puts the filter before the required separator, so requested coverage and filtering are not forwarded correctly. Determine the mode from evaluated MSBuild properties, including imported/SDK defaults, and add an imported-property regression case.

2 resolved since last review

Review effort: Balanced

…rops MTP config

- Move dashboard port discovery file from os.TempDir() into the 0o700 ~/.azd/azd-app/<hash> state directory and fail closed if port or token persistence fails
- Strip JSONC comments and trailing commas before unmarshaling global.json in DotnetTestRunner
- Evaluate ancestor Directory.Build.props and explicit MSBuild <Import> files when detecting MTP opt-in properties

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Nov 12, 2026
…ccheck QF1001

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Nov 12, 2026
@jongio
jongio requested a balanced review from Copilot November 12, 2026 05:41

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.

🟡 Changes recommended

Case-insensitive matching of Directory.Build.props can select an unused file on case-sensitive filesystems, causing the wrong test runner and incompatible filtering or coverage arguments.

1 open issue

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Nov 12, 2026
@jongio
jongio requested a balanced review from Copilot November 12, 2026 06:07

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.

🔵 Needs a closer look

Human assessment is needed to evaluate omitted moderate findings affecting conditional .NET runner detection, TCP health-check behavior, and stale service state during streaming refreshes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@jongio
jongio merged commit 21b6b3d into main Nov 12, 2026
20 checks passed
github-actions Bot added a commit that referenced this pull request Nov 12, 2026
@jongio
jongio deleted the fix/dashboard-health-and-dotnet-test branch November 12, 2026 06:37
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.

2 participants