Repository navigation
Resolve relative dashboard data directory against the AppHost directory - #21525
David Fowler (davidfowl) merged 2 commits into
Conversation
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>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21525Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21525" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 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
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
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>
Tests selector52 / 100 PR test projects · 4 PR jobs, from 2 changed files. Selected PR test projects (52 / 100)
Selected PR jobs (4)
How these were chosen — grouped by what changed
🔧 show 46
🧪 📦 affected project 📦 affected project Job reasons
Selection computed for commit |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Pull request created: #2014
|
|
📝 Documentation has been drafted in microsoft/aspire.dev#2014 targeting No gating signals fired (docs_optional), but this is a user-visible behavior change to a documented setting: relative Note This draft PR needs human review before merging. |

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.ConfigureEnvironmentVariablespassesDashboard:Data:Directoryand anyASPIRE_DASHBOARD_*config keys to the dashboard unchanged.ExecutableResourceuses the dashboard's install directory as its working directory (dashboardWorkingDirectory).DashboardRunStore.GetDataRootcallsPath.GetFullPath(dataRoot), so./dashboard-dataresolves to<dashboard install dir>/dashboard-data.Fix
After the data-directory variable is forwarded, if its value is not fully qualified and
AppHost:Directoryis known, the AppHost resolves it withPath.GetFullPath(value, appHostDirectory). The forwarded key is matched case-insensitively, because automaticASPIRE_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, theASPIRE_DASHBOARD_DATA_DIRECTORYalias and a lowercaseaspire_dashboard_data_directoryalias.ConfigureEnvironmentVariables_PreservesAbsoluteDashboardDataDirectory.main(test only)Expected: "/tmp/apphost-project/dashboard-data",Actual: "./dashboard-data"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:
playground/CustomResourceswith the dashboard project reference skipped, so the dashboard starts fromartifacts/bin/Aspire.Dashboard/...the way an installed bundle does.Dashboard__Data__Directory=./dashboard-data.Before (main):
After (this PR):
In both runs the dashboard served HTTP on its frontend URL. There is no UI change, so no screenshots.
Checklist
🤖 Posted by AspireAgent (AI Agent)