-
Notifications
You must be signed in to change notification settings - Fork 762
Show --log-level debug hint when pipeline fails #12603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Modified ConsoleActivityLogger to accept optional commandName in SetFinalResult - Display help message when pipeline fails with command name - Updated PipelineCommandBase to pass command name to logger Co-authored-by: davidfowl <[email protected]>
| AnsiConsole.MarkupLine(_finalStatusHeader!); | ||
|
|
||
| // If pipeline failed, show help message about using --log-level debug | ||
| if (_finalStatusHeader.Contains("PIPELINE FAILED") && !string.IsNullOrEmpty(_commandName)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot instead of doing this crude Contains check, we should store the bool from the call to SetFinalResult in a field and use it here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Changed to use _pipelineSucceeded boolean field instead of string Contains check. (e8bed6c)
|
@copilot The command name should be passed in the ctor of ConsoleActivityLogger |
Store the succeeded value from SetFinalResult in _pipelineSucceeded field and use !_pipelineSucceeded instead of checking if string contains "PIPELINE FAILED" Co-authored-by: davidfowl <[email protected]>
Move command name from SetFinalResult parameter to constructor parameter. This is cleaner since the command name doesn't change throughout the lifecycle of the logger. Co-authored-by: davidfowl <[email protected]>
|
@copilot Why is the command name nullable? It should never be null. The other changes look good. |
The commandName parameter is always provided from PipelineCommandBase.Name and should never be null. Changed constructor signature to make it a required parameter and removed null checks. Co-authored-by: davidfowl <[email protected]>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12603Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12603" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the ConsoleActivityLogger to provide contextual help messages when pipeline commands (deploy, publish, do) fail. The changes enable the logger to display a helpful suggestion to re-run the command with --log-level debug for more diagnostic information.
Key changes:
- Added
commandNameparameter toConsoleActivityLoggerconstructor to track which CLI command is being executed - Modified
WriteSummary()to display a help message when the pipeline fails, suggesting the user re-run with debug logging enabled - Updated field ordering to follow common C# conventions
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Aspire.Cli/Utils/ConsoleActivityLogger.cs | Added _commandName field and parameter, implemented help message display in WriteSummary() when pipeline fails |
| src/Aspire.Cli/Commands/PipelineCommandBase.cs | Updated ConsoleActivityLogger instantiation to pass this.Name as the command name |
| private readonly string _commandName; | ||
| private readonly object _lock = new(); |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The new field _commandName is placed between _hostEnvironment and _lock, disrupting the logical grouping of fields. Consider placing _commandName immediately after _hostEnvironment (line 20) and before _lock to maintain better field organization, as both _hostEnvironment and _commandName are constructor parameters that store configuration, while _lock begins the section of runtime state fields.
| private readonly string _commandName; | |
| private readonly object _lock = new(); | |
| private readonly object _lock = new(); | |
| private readonly string _commandName; |
| private string? _finalStatusHeader; | ||
| private bool _pipelineSucceeded; |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The _pipelineSucceeded field is placed after _finalStatusHeader but at a different location in the class than where other instance fields are declared (lines 19-37). For consistency and maintainability, consider moving both _finalStatusHeader and _pipelineSucceeded to the top of the class with the other private fields (after line 37, before the constants section starting at line 41).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot apply changes based on this feedback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Moved _finalStatusHeader and _pipelineSucceeded fields to the top with other private fields for better organization. (47810f2)
Move _finalStatusHeader and _pipelineSucceeded fields to the top with other private fields for better organization and consistency. Co-authored-by: davidfowl <[email protected]>
|
@copilot When I run a command like: aspire do foo I see 23:06:32 (pipeline execution) → Starting pipeline execution...
|
- Changed message to generic "For more details, add --log-level debug/trace to the command." - Suppress help message when user already passed --log-level debug or trace - Replaced commandName parameter with isDebugOrTraceLoggingEnabled flag Co-authored-by: davidfowl <[email protected]>
|
/backport to release/13.0 |
|
Started backporting to release/13.0: https://github.com/dotnet/aspire/actions/runs/19021647033 |
Add help message when pipeline fails
Fixes the issue where users don't know what to do when the pipeline fails because errors are cleaned up and there's no guidance on how to get more diagnostic information.
Problem
When CLI pipeline commands (
aspire deploy,aspire publish,aspire do) fail:docker buildx)--log-level debugto get detailed diagnosticsSolution
Modified the pipeline summary to display a helpful message when the pipeline fails, guiding users to add
--log-level debug/tracefor detailed error information. The message is suppressed when debug or trace logging is already enabled to avoid redundant advice.Changes Made
ConsoleActivityLogger.cs:
_isDebugOrTraceLoggingEnabledreadonly field, passed via constructor_pipelineSucceededfield to track if pipeline succeededisDebugOrTraceLoggingEnabledparameterSetFinalResult()to store only thesucceededvalueWriteSummary()to display help message when pipeline fails (only if not already in debug/trace mode)PipelineCommandBase.cs:
--log-level debugor--log-level tracewas passedConsoleActivityLoggerinstantiation to pass the debug/trace logging flaglogger.SetFinalResult()to pass only the succeeded booleanExample Output
Before (when pipeline fails):
After (when pipeline fails without --log-level debug):
After (when pipeline fails WITH --log-level debug/trace):
(No help message shown since user already has debug/trace logging enabled)
Implementation Details
succeeded: false)--log-level debugor--log-level traceaspire deploy,aspire publish,aspire do <step>Testing
<issue_title>When the pipeline fails its hard to see errors</issue_title>
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.