Skip to content

Commit bc3c312

Browse files
committed
fix(setup): avoid retrying WSL platform mutation
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 117b368d-db79-4380-bc7d-de26acc3f15b
1 parent a9ad12c commit bc3c312

3 files changed

Lines changed: 36 additions & 2 deletions

File tree

‎src/OpenClaw.SetupEngine/PreflightWslStep.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ internal EnsureWslPlatformStep(
291291

292292
public override string Id => "ensure-wsl-platform";
293293
public override string DisplayName => "Prepare WSL platform";
294-
public override bool CanRetry => true;
294+
public override bool CanRetry => false;
295295

296296
public override async Task<StepResult> ExecuteAsync(SetupContext ctx, CancellationToken ct)
297297
{

‎tests/OpenClaw.SetupEngine.Tests/SetupStepsTests.cs‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,6 +1419,39 @@ public async Task EnsureWslPlatform_PropagatesElevationCancellationWithoutReinsp
14191419
Assert.Equal(2, commands.Calls.Count);
14201420
}
14211421

1422+
[Fact]
1423+
public async Task EnsureWslPlatform_ElevationCancellationIsNotRetriedByPipeline()
1424+
{
1425+
var installCalls = 0;
1426+
var commands = new FakeCommandRunner(args => args switch
1427+
{
1428+
["--version"] => Ok("WSL version: 2.7.3.0\n"),
1429+
["--status"] => new CommandResult(
1430+
1,
1431+
"",
1432+
"Error code: Wsl/WSL_E_WSL_OPTIONAL_COMPONENT_REQUIRED",
1433+
TimeSpan.Zero,
1434+
TimedOut: false),
1435+
_ => Fail($"unexpected args: {string.Join(' ', args)}"),
1436+
});
1437+
var ctx = CreateContext(commands: commands);
1438+
var step = new EnsureWslPlatformStep((_, _) =>
1439+
{
1440+
installCalls++;
1441+
return Task.FromResult(
1442+
StepResult.Fail("WSL platform install was cancelled at the elevation prompt."));
1443+
});
1444+
var pipeline = new SetupPipeline([step]);
1445+
1446+
var result = await pipeline.RunAsync(ctx);
1447+
1448+
Assert.Equal(PipelineOutcome.Failed, result.Outcome);
1449+
Assert.Equal(step.Id, result.FailedStepId);
1450+
Assert.Contains("elevation prompt", result.Message);
1451+
Assert.Equal(1, installCalls);
1452+
Assert.Equal(2, commands.Calls.Count);
1453+
}
1454+
14221455
[Fact]
14231456
public async Task PreflightWsl_UnclassifiedStatusFailureFailsClosed()
14241457
{

‎tests/OpenClaw.SetupEngine.Tests/WslPlatformInstallDiagnosticsTests.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ await Assert.ThrowsAnyAsync<OperationCanceledException>(() =>
4848
}
4949

5050
[Fact]
51-
public void EnsureWslPlatform_IsRetryable() => Assert.True(new EnsureWslPlatformStep().CanRetry);
51+
public void EnsureWslPlatform_DoesNotRetryElevatedMutation() =>
52+
Assert.False(new EnsureWslPlatformStep().CanRetry);
5253

5354
private sealed class DelayedHandler : HttpMessageHandler
5455
{

0 commit comments

Comments
 (0)