Repository navigation
Revert ProjectLocator walk-stop behavior from #18683 - #18700
Conversation
Remove the 'stop config walk at workspace root' logic that prevented the parent directory walk from continuing past aspire.config.json or .aspire/settings.json when they had no appHost path configured. Also remove the two corresponding unit tests that validated the walk-stop behavior.
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 18700Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 18700" |
There was a problem hiding this comment.
Pull request overview
This PR reverts the "stop config walk at workspace root" behavior in ProjectLocator that was introduced as part of #18683. It restores the pre-#18683 behavior where GetAppHostProjectFileFromSettingsAsync continues walking up parent directories even when an aspire.config.json or .aspire/settings.json exists at the current level but does not specify an AppHost path.
Changes:
- Removed the outer
if (aspireConfig is not null)wrapper and the trailingreturn null;statements that previously halted the parent-directory walk at the workspace root, collapsing the config check back to a singleaspireConfig?.AppHost?.Path is { }guard. - Deleted the two regression tests that asserted the walk stopped at the workspace root (
GetAppHostFromSettings_StopsAtWorkspaceRootWhenLegacySettingsHasNoAppHostPathandGetAppHostFromSettings_StopsAtWorkspaceRootWhenAspireConfigJsonHasNoAppHostPath).
The revert is mechanically clean: control flow, brace balance, and indentation are all correct, the NUL-byte/invalid-path validation and warning paths are preserved, and no orphaned symbols or dangling references remain. The .aspire/settings.json sentinel that TemporaryWorkspace.CreateForCli plants still serves its separate ConfigurationHelper.GetConfigRootDirectory purpose. The main consideration for a human reviewer is that this removes a guard (and its test coverage) that #18683 added to prevent stale parent-directory config from contaminating results, so confirming the revert is intended and does not reintroduce that problem is worthwhile.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Aspire.Cli/Projects/ProjectLocator.cs | Removes the walk-stop guard/return null; statements so the directory walk again continues to parent directories when no AppHost path is configured at the current level. |
| tests/Aspire.Cli.Tests/Projects/ProjectLocatorTests.cs | Deletes the two unit tests that verified the now-removed walk-stop behavior. |
Tests selector (audit mode)The full test matrix and all jobs still run in audit mode. The tests and jobs below are what selective CI would run under enforcement. 2 / 99 test projects · 5 jobs, from 2 changed files. Selected test projects (2 / 99)
Selected jobs (5)
How these were chosen — grouped by what changed📦 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. |
|
[automated] The revert itself looks clean — it's the exact inverse of the Both deleted tests plant a parent config that points at await File.WriteAllTextAsync(staleConfigPath, """{ "appHost": { "path": "Stale.csproj" } }""");
// ...
Assert.Null(foundAppHost);Under the reverted (walk-past) behavior the walk does reach the parent, resolves Suggestion: add positive guards that would fail if the walk-stop were ever reintroduced. Two that map directly to the two reverted branches ( [Fact]
public async Task GetAppHostFromSettings_AspireConfigJsonWithoutAppHostPath_ContinuesWalkingToParentConfig()
{
// A common real case: a minimal per-directory config such as { "channel": "daily" }
// with the actual AppHost configured in a parent directory. The walk must not stop
// at the child config just because it has no appHost.path.
using var workspace = TemporaryWorkspace.CreateForCli(outputHelper);
var parentDir = workspace.WorkspaceRoot.CreateSubdirectory("parent");
var appHostFile = new FileInfo(Path.Combine(parentDir.FullName, "AppHost.csproj"));
await File.WriteAllTextAsync(appHostFile.FullName, "Not a real apphost");
await File.WriteAllTextAsync(
Path.Combine(parentDir.FullName, AspireConfigFile.FileName),
"""{ "appHost": { "path": "AppHost.csproj" } }""");
var childDir = parentDir.CreateSubdirectory("child");
await File.WriteAllTextAsync(
Path.Combine(childDir.FullName, AspireConfigFile.FileName),
"""{ "channel": "daily" }""");
var executionContext = CreateExecutionContext(childDir);
var projectLocator = CreateProjectLocator(executionContext);
var foundAppHost = await projectLocator.GetAppHostFromSettingsAsync(CancellationToken.None).DefaultTimeout();
Assert.Equal(appHostFile.FullName, foundAppHost?.FullName);
}
[Fact]
public async Task GetAppHostFromSettings_LegacySettingsWithoutAppHostPath_ContinuesWalkingToParentConfig()
{
// Same guard for the legacy .aspire/settings.json branch.
using var workspace = TemporaryWorkspace.CreateForCli(outputHelper);
var parentDir = workspace.WorkspaceRoot.CreateSubdirectory("parent");
var appHostFile = new FileInfo(Path.Combine(parentDir.FullName, "AppHost.csproj"));
await File.WriteAllTextAsync(appHostFile.FullName, "Not a real apphost");
await File.WriteAllTextAsync(
Path.Combine(parentDir.FullName, AspireConfigFile.FileName),
"""{ "appHost": { "path": "AppHost.csproj" } }""");
var childDir = parentDir.CreateSubdirectory("child");
var childSettingsDir = childDir.CreateSubdirectory(".aspire");
await File.WriteAllTextAsync(Path.Combine(childSettingsDir.FullName, "settings.json"), "{}");
var executionContext = CreateExecutionContext(childDir);
var projectLocator = CreateProjectLocator(executionContext);
var foundAppHost = await projectLocator.GetAppHostFromSettingsAsync(CancellationToken.None).DefaultTimeout();
Assert.Equal(appHostFile.FullName, foundAppHost?.FullName);
}Two notes on the shape:
Optionally, a "parent config points at a nonexistent path → Note: this code is a sketch grounded in the existing test conventions in this file; it hasn't been run against the branch yet — worth a quick local run before committing. |
|
No test caught this originally? |
|
There is no tests for this behavior one way or another. Reverting it because it doesn't need to change, and I don't know whether it is a bug fix or not. |
Jose Perez Rodriguez (joperezr)
left a comment
There was a problem hiding this comment.
Approving since this is just the revert of an unintended change. We should do a follow up that adds tests to catches regressions agains the behavior (assuming it is the behavior we want)
|
✅ No documentation update needed. docs_optional → internal_refactor No signals triggered (signal_count = 0). This PR reverts internal |
Description
Reverts the ProjectLocator "stop config walk at workspace root" behavior introduced in #18683.
The change removed:
if (aspireConfig is not null)wrapper that prevented the parent directory walk from continuing pastaspire.config.jsonwhen it had noappHost.pathconfiguredreturn null;after the.aspire/settings.jsonblock that similarly stopped the walkGetAppHostFromSettings_StopsAtWorkspaceRootWhenLegacySettingsHasNoAppHostPathandGetAppHostFromSettings_StopsAtWorkspaceRootWhenAspireConfigJsonHasNoAppHostPath)Validation
All 4606 CLI tests pass (0 failures, 36 skipped for platform reasons).