Conversation
Reviewer's GuideAdjusts how command and dependency failure output is formatted by prefixing dependency trees with Sequence diagram for CLI dependency failure handling and output formattingsequenceDiagram
actor User
participant CLI
participant Executor
participant DependencyError
participant ExecuteError
participant Logger
participant Stderr
User->>CLI: invoke lets command
CLI->>Executor: run command with dependencies
Executor-->>CLI: error (wrapped in DependencyError)
CLI->>CLI: errors.As(err, &depErr)
alt dependency_error
CLI->>DependencyError: PrintDependencyTree(depErr, Stderr)
DependencyError->>Stderr: write lets:-prefixed tree
CLI->>DependencyError: FailureMessage()
DependencyError->>ExecuteError: unwrap to ExecuteError
ExecuteError->>ExecuteError: Cause()
ExecuteError-->>DependencyError: underlying error
DependencyError-->>CLI: concise failure message
CLI->>Logger: Errorf("%s", failureMessage)
CLI->>CLI: getExitCode(err, 1)
CLI-->>User: process exit with code
else other_error
CLI->>Logger: Errorf("%s", err.Error())
CLI->>CLI: getExitCode(err, 1)
CLI-->>User: process exit with code
end
Class diagram for updated error types DependencyError and ExecuteErrorclassDiagram
class DependencyError {
+[]string Chain
+error Err
+Error() string
+Unwrap() error
+ExitCode() int
+FailureMessage() string
}
class ExecuteError {
+Error() string
+Unwrap() error
+Cause() error
+ExitCode() int
}
DependencyError --> ExecuteError : may_wrap
ExecuteError --> error : wraps
DependencyError --> error : wraps
class CLI {
+Main(version string, buildDate string) int
}
CLI --> DependencyError : handles
CLI --> ExecuteError : receives_via_error_chain
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="tests/command_cmd.bats" line_range="43-48" />
<code_context>
# we can not guarantee that all commands will run and complete.
# But error message must be in the output.
- assert_output --partial "failed to run command 'cmd-as-map-error': exit status 2"
+ assert_output --partial "lets: cmd-as-map-error"
+ assert_output --partial "lets: exit status 2"
}
</code_context>
<issue_to_address>
**suggestion (testing):** Assert ordering and avoid accidentally allowing the old verbose error format
The new expectations only verify that the `lets:` lines appear somewhere in the output. To better capture the intended behavior and prevent regressions, please also (1) assert that the command line appears before the `exit status` line, and (2) assert that the old verbose message (`"failed to run command 'cmd-as-map-error': exit status 2"`) does not appear.
```suggestion
# as there is no guarantee in which order cmds runs
# we can not guarantee that all commands will run and complete.
# But error message must be in the output.
assert_output --partial "lets: cmd-as-map-error"
assert_output --partial "lets: exit status 2"
# Ensure the command line appears before the exit status line.
local cmd_prefix exit_prefix
cmd_prefix=${output%%lets: cmd-as-map-error*}
exit_prefix=${output%%lets: exit status 2*}
# Sanity check: both fragments must be present
[ "$cmd_prefix" != "$output" ]
[ "$exit_prefix" != "$output" ]
# cmd-as-map-error must appear before the exit status
(( ${#cmd_prefix} < ${#exit_prefix} ))
# Ensure the old verbose error format is not present.
refute_output --partial "failed to run command 'cmd-as-map-error': exit status 2"
}
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| # as there is no guarantee in which order cmds runs | ||
| # we can not guarantee that all commands will run and complete. | ||
| # But error message must be in the output. | ||
| assert_output --partial "failed to run command 'cmd-as-map-error': exit status 2" | ||
| assert_output --partial "lets: cmd-as-map-error" | ||
| assert_output --partial "lets: exit status 2" | ||
| } |
There was a problem hiding this comment.
suggestion (testing): Assert ordering and avoid accidentally allowing the old verbose error format
The new expectations only verify that the lets: lines appear somewhere in the output. To better capture the intended behavior and prevent regressions, please also (1) assert that the command line appears before the exit status line, and (2) assert that the old verbose message ("failed to run command 'cmd-as-map-error': exit status 2") does not appear.
| # as there is no guarantee in which order cmds runs | |
| # we can not guarantee that all commands will run and complete. | |
| # But error message must be in the output. | |
| assert_output --partial "failed to run command 'cmd-as-map-error': exit status 2" | |
| assert_output --partial "lets: cmd-as-map-error" | |
| assert_output --partial "lets: exit status 2" | |
| } | |
| # as there is no guarantee in which order cmds runs | |
| # we can not guarantee that all commands will run and complete. | |
| # But error message must be in the output. | |
| assert_output --partial "lets: cmd-as-map-error" | |
| assert_output --partial "lets: exit status 2" | |
| # Ensure the command line appears before the exit status line. | |
| local cmd_prefix exit_prefix | |
| cmd_prefix=${output%%lets: cmd-as-map-error*} | |
| exit_prefix=${output%%lets: exit status 2*} | |
| # Sanity check: both fragments must be present | |
| [ "$cmd_prefix" != "$output" ] | |
| [ "$exit_prefix" != "$output" ] | |
| # cmd-as-map-error must appear before the exit status | |
| (( ${#cmd_prefix} < ${#exit_prefix} )) | |
| # Ensure the old verbose error format is not present. | |
| refute_output --partial "failed to run command 'cmd-as-map-error': exit status 2" | |
| } |
Summary
lets:on the first linelets: exit status 1Testing
go test ./...lets test-bats dependency_failure_tree.batsSummary by Sourcery
Adjust command failure reporting to present a clearer, lets-prefixed dependency tree and a concise final status line.
Bug Fixes:
Enhancements:
lets:label and adjust indentation for better readability.lets:-prefixed status line in the CLI error output.Documentation:
Tests: