Don't swallow errors from ExecutionConfigurationBuilder#15475
Don't swallow errors from ExecutionConfigurationBuilder#15475afscrome wants to merge 1 commit intomicrosoft:mainfrom
Conversation
…ce fails to start.
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15475Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15475" |
There was a problem hiding this comment.
Pull request overview
Stops swallowing exceptions captured during execution-configuration resolution so resource startup failures surface actionable errors (instead of silently transitioning to FailedToStart).
Changes:
- Preserve and rethrow
ExecutionConfigurationBuilder/resolution exceptions usingExceptionDispatchInfo.Throw(...)for executables. - Preserve and rethrow
ExecutionConfigurationBuilder/resolution exceptions usingExceptionDispatchInfo.Throw(...)for containers (while keeping existingFailedToApplyEnvironmentExceptionbehavior for run-args failures).
| if (configuration.Exception is not null) | ||
| { | ||
| throw new FailedToApplyEnvironmentException(); | ||
| ExceptionDispatchInfo.Throw(configuration.Exception); | ||
| } |
There was a problem hiding this comment.
This change makes configuration.Exception (from ExecutionConfigurationGathererContext.ResolveAsync) propagate instead of being converted into FailedToApplyEnvironmentException. Please add a unit test in DcpExecutorTests that exercises a failing value-provider resolution (e.g., missing endpoint reference) and asserts that the failure is surfaced via error logging / OnResourceFailedToStart rather than being silently swallowed.
| ExceptionDispatchInfo.Throw(configuration.Exception); | ||
| } | ||
| if (failedToApplyRunArgs) | ||
| { |
There was a problem hiding this comment.
Same as above for containers: please add coverage for the configuration.Exception path in container startup so regressions don’t reintroduce the "FailedToStart with no logs" behavior (assert an error is logged and the container is marked failed to start).
| ExceptionDispatchInfo.Throw(configuration.Exception); | |
| } | |
| if (failedToApplyRunArgs) | |
| { | |
| resourceLogger.LogError(configuration.Exception, "Failed to configure container startup."); | |
| throw new FailedToApplyEnvironmentException(); | |
| } | |
| if (failedToApplyRunArgs) | |
| { | |
| resourceLogger.LogError("Failed to apply environment configuration for container startup."); |
| if (configuration.Exception is not null) | ||
| { | ||
| throw new FailedToApplyEnvironmentException(); | ||
| ExceptionDispatchInfo.Throw(configuration.Exception); |
There was a problem hiding this comment.
Why not use InnerException property to remember the original one (contiguration.Exception) when constructing the FailedToApplyEnvironmentException?
I am also not thrilled by this code using ExceptionDispatchInfo--seems like a low-level API that is not really necessary here. Maybe we can eliminate it as part of this PR.
Description
Don't swallow errors if a resource fails to start due to an exception from
ExecutionConfigurationBuilder.Some improvements could be made to avoid the massive stack trace the current error gives, but getting an error is a big improvement over the reosurce showing
FailedToStartwithout any logs to suggest why.One way to encounter this is:
Which now gives the error:
Fixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: