Skip to content

Resolve relative dashboard data directory against the AppHost directory - #21525

Merged
David Fowler (davidfowl) merged 2 commits into
mainfrom
aspireagent/fix-19782-dashboard-data-directory
Nov 1, 2026
Merged

David Fowler (davidfowl) merged 2 commits into
mainfrom
aspireagent/fix-19782-dashboard-data-directory

Conversation

@davidfowl

@davidfowl David Fowler (davidfowl) commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Description

A relative dashboard data directory (Dashboard:Data:Directory / ASPIRE_DASHBOARD_DATA_DIRECTORY) was resolved against the dashboard's working directory, which is its install or bundle directory, rather than the AppHost directory. Data was written under the dashboard binaries, and if that directory is read-only, writing it can fail.

Fixes #19782

Root cause

  • DashboardEventHandlers.ConfigureEnvironmentVariables passes Dashboard:Data:Directory and any ASPIRE_DASHBOARD_* config keys to the dashboard unchanged.
  • The dashboard ExecutableResource uses the dashboard's install directory as its working directory (dashboardWorkingDirectory).
  • The dashboard's DashboardRunStore.GetDataRoot calls Path.GetFullPath(dataRoot), so ./dashboard-data resolves to <dashboard install dir>/dashboard-data.

Fix

After the data-directory variable is forwarded, if its value is not fully qualified and AppHost:Directory is known, the AppHost resolves it with Path.GetFullPath(value, appHostDirectory). The forwarded key is matched case-insensitively, because automatic ASPIRE_DASHBOARD_* forwarding keeps the key's original spelling. Absolute paths are left as they are. This takes the non-breaking option from the issue: relative paths keep working, now relative to the AppHost, which matches other AppHost-relative paths.

Evidence

Unit tests (fail before, pass after)

New tests in DashboardEventHandlersTests:

  • ConfigureEnvironmentVariables_ResolvesRelativeDashboardDataDirectoryFromAppHostDirectory, a theory over the config key, the ASPIRE_DASHBOARD_DATA_DIRECTORY alias and a lowercase aspire_dashboard_data_directory alias.
  • ConfigureEnvironmentVariables_PreservesAbsoluteDashboardDataDirectory.
Result
main (test only) 2 failed / 49. Expected: "/tmp/apphost-project/dashboard-data", Actual: "./dashboard-data"
This PR DashboardEventHandlersTests + DashboardResourceTests: 91/91 passed. The lowercase alias case, added after review, failed against the first head, c8a4239 (1/50).

E2E (real AppHost, real DCP, built dashboard binary)

Setup:

  • Ran playground/CustomResources with the dashboard project reference skipped, so the dashboard starts from artifacts/bin/Aspire.Dashboard/... the way an installed bundle does.
  • Ran from the AppHost directory with Dashboard__Data__Directory=./dashboard-data.
  • Inspected the running dashboard process's environment and checked where its data was created.

Before (main):

ASPIRE_DASHBOARD_DATA_DIRECTORY=./dashboard-data
cwd=/root/aspire/artifacts/bin/Aspire.Dashboard/Debug/net11.0
MISSING .../playground/CustomResources/CustomResources.AppHost/dashboard-data
EXISTS  .../artifacts/bin/Aspire.Dashboard/Debug/net11.0/dashboard-data/runs/20261031T051312343Z

After (this PR):

ASPIRE_DASHBOARD_DATA_DIRECTORY=/root/aspire/playground/CustomResources/CustomResources.AppHost/dashboard-data
cwd=/root/aspire/artifacts/bin/Aspire.Dashboard/Debug/net11.0
EXISTS  .../playground/CustomResources/CustomResources.AppHost/dashboard-data/runs/20261031T051159942Z
MISSING .../artifacts/bin/Aspire.Dashboard/Debug/net11.0/dashboard-data

In both runs the dashboard served HTTP on its frontend URL. There is no UI change, so no screenshots.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No

🤖 Posted by AspireAgent (AI Agent)

The dashboard runs with its install directory as the working directory, so a
relative Dashboard:Data:Directory was resolved under the dashboard bundle
instead of the AppHost directory.

Fixes #19782

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

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21525

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21525"

@github-actions

This comment has been minimized.

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

A case-sensitive lookup causes mixed- or lowercase dashboard data-directory aliases to bypass path resolution, leaving relative paths rooted under the dashboard bundle.

1 open issue
What changed in this PR

This PR addresses #19782 by resolving relative dashboard persistence paths against the AppHost directory rather than the dashboard’s install directory.

Changes:

  • Resolves relative data-directory values supplied through either configuration key or environment alias.
  • Preserves absolute paths.
  • Adds regression tests for relative-path resolution and absolute-path preservation.
File Description
tests/​Aspire.Hosting.Tests/​Dashboard/​DashboardEventHandlersTests.cs Adds path-resolution tests and a shared environment-configuration helper.
src/​Aspire.Hosting/​Dashboard/​DashboardEventHandlers.cs Resolves forwarded relative data directories against AppHost:Directory.

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

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

Copy link
Copy Markdown
Contributor

Tests selector

52 / 100 PR test projects · 4 PR jobs, from 2 changed files.

Selected PR test projects (52 / 100)

Aspire.Cli.EndToEnd.Tests, Aspire.Hosting.Analyzers.Tests, Aspire.Hosting.Azure.EntraId.Tests, Aspire.Hosting.Azure.Kubernetes.Tests, Aspire.Hosting.Azure.Kusto.Tests, Aspire.Hosting.Azure.Provisioning.Tests, Aspire.Hosting.Azure.Tests, Aspire.Hosting.Blazor.Tests, Aspire.Hosting.Browsers.Tests, Aspire.Hosting.CodeGeneration.Go.Tests, Aspire.Hosting.CodeGeneration.Java.Tests, Aspire.Hosting.CodeGeneration.Python.Tests, Aspire.Hosting.CodeGeneration.Rust.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Containers.Tests, Aspire.Hosting.DevTunnels.Tests, Aspire.Hosting.Docker.Tests, Aspire.Hosting.Dotnet.Tests, Aspire.Hosting.DotnetTool.Tests, Aspire.Hosting.EntityFrameworkCore.Tests, Aspire.Hosting.Foundry.Tests, Aspire.Hosting.Garnet.Tests, Aspire.Hosting.Go.Tests, Aspire.Hosting.Java.Tests, Aspire.Hosting.JavaScript.Tests, Aspire.Hosting.Kafka.Tests, Aspire.Hosting.Keycloak.Tests, Aspire.Hosting.Kubernetes.Tests, Aspire.Hosting.Maui.Tests, Aspire.Hosting.Milvus.Tests, Aspire.Hosting.MongoDB.Tests, Aspire.Hosting.MySql.Tests, Aspire.Hosting.Nats.Tests, Aspire.Hosting.OpenAI.Tests, Aspire.Hosting.Oracle.Tests, Aspire.Hosting.Orleans.Tests, Aspire.Hosting.PostgreSQL.Tests, Aspire.Hosting.Python.Tests, Aspire.Hosting.Qdrant.Tests, Aspire.Hosting.RabbitMQ.Tests, Aspire.Hosting.Radius.Tests, Aspire.Hosting.Redis.Tests, Aspire.Hosting.RemoteHost.Tests, Aspire.Hosting.Rust.Tests, Aspire.Hosting.Seq.Tests, Aspire.Hosting.SqlServer.Tests, Aspire.Hosting.Testing.Tests, Aspire.Hosting.Tests, Aspire.Hosting.Valkey.Tests, Aspire.Hosting.Yarp.Tests, Aspire.Playground.Tests, Aspire.Templates.Tests

Selected PR jobs (4)

cli-starter-validation, extension-e2e, polyglot, typescript-api-compat


How these were chosen — grouped by what changed

⚠️ 46 of the 52 selected test projects come from a single change — src/Aspire.Hosting/Dashboard/DashboardEventHandlers.cs.

🔧 src/Aspire.Hosting/Dashboard/DashboardEventHandlers.cs (changed source)
→ 46 via the project graph

show 46

Aspire.Hosting.Analyzers.Tests (2 hops), Aspire.Hosting.Azure.EntraId.Tests (2 hops), Aspire.Hosting.Azure.Kubernetes.Tests (2 hops), Aspire.Hosting.Azure.Kusto.Tests (2 hops), Aspire.Hosting.Azure.Provisioning.Tests (3 hops), Aspire.Hosting.Azure.Tests, Aspire.Hosting.Browsers.Tests (2 hops), Aspire.Hosting.CodeGeneration.Go.Tests, Aspire.Hosting.CodeGeneration.Java.Tests, Aspire.Hosting.CodeGeneration.Python.Tests, Aspire.Hosting.CodeGeneration.Rust.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Containers.Tests (2 hops), Aspire.Hosting.DevTunnels.Tests (2 hops), Aspire.Hosting.Docker.Tests (2 hops), Aspire.Hosting.DotnetTool.Tests (2 hops), Aspire.Hosting.EntityFrameworkCore.Tests (2 hops), Aspire.Hosting.Foundry.Tests (2 hops), Aspire.Hosting.Garnet.Tests (2 hops), Aspire.Hosting.Go.Tests (2 hops), Aspire.Hosting.Java.Tests (2 hops), Aspire.Hosting.JavaScript.Tests (2 hops), Aspire.Hosting.Kafka.Tests (2 hops), Aspire.Hosting.Keycloak.Tests (2 hops), Aspire.Hosting.Kubernetes.Tests (2 hops), Aspire.Hosting.Maui.Tests, Aspire.Hosting.Milvus.Tests (2 hops), Aspire.Hosting.MongoDB.Tests (2 hops), Aspire.Hosting.MySql.Tests (2 hops), Aspire.Hosting.Nats.Tests (2 hops), Aspire.Hosting.OpenAI.Tests (2 hops), Aspire.Hosting.Oracle.Tests (2 hops), Aspire.Hosting.Orleans.Tests (2 hops), Aspire.Hosting.PostgreSQL.Tests (2 hops), Aspire.Hosting.Python.Tests (2 hops), Aspire.Hosting.Qdrant.Tests (2 hops), Aspire.Hosting.RabbitMQ.Tests (2 hops), Aspire.Hosting.Redis.Tests (2 hops), Aspire.Hosting.RemoteHost.Tests, Aspire.Hosting.Rust.Tests (2 hops), Aspire.Hosting.Seq.Tests (2 hops), Aspire.Hosting.SqlServer.Tests (2 hops), Aspire.Hosting.Testing.Tests (2 hops), Aspire.Hosting.Valkey.Tests (2 hops), Aspire.Hosting.Yarp.Tests (2 hops), Aspire.Playground.Tests

🧪 tests/Aspire.Hosting.Tests/Dashboard/DashboardEventHandlersTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Tests
→ 3 via the project graph: Aspire.Hosting.Blazor.Tests, Aspire.Hosting.Dotnet.Tests, Aspire.Hosting.Radius.Tests

📦 affected project Aspire.Hosting.Dotnet
→ 2 tests: Aspire.Cli.EndToEnd.Tests, Aspire.Templates.Tests

📦 affected project Aspire.Hosting
→ 1 test: Aspire.Cli.EndToEnd.Tests

Job reasons

Job Triggered by
cli-starter-validation affected project Aspire.Hosting.Dotnet
extension-e2e • src/Aspire.Hosting/Dashboard/DashboardEventHandlers.cs
• affected project Aspire.Hosting
polyglot • affected project Aspire.Hosting
• affected project Aspire.Hosting.Azure.Provisioning
typescript-api-compat affected project Aspire.Hosting

Selection computed for commit 0d75c5b.

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.

🟢 Approval recommended

No active review issues are recorded for the change resolving relative dashboard persistence paths against the AppHost directory.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@davidfowl
David Fowler (davidfowl) merged commit 1bccada into main Nov 1, 2026
688 of 692 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.0 milestone Nov 1, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #2014

Generated by PR Documentation Check · copilot · auto · 23.5 AIC · ⌖ 1.14 AIC · ⊞ 7.1K

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#2014 targeting release/17.0.

No gating signals fired (docs_optional), but this is a user-visible behavior change to a documented setting: relative ASPIRE_DASHBOARD_DATA_DIRECTORY / Dashboard:(redacted) now resolves against the AppHost directory. Updated app-host/configuration.mdx`.

Note

This draft PR needs human review before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Dashboard] Resolve relative persistence directories from the AppHost

3 participants