Repository navigation
Conversation
reportOutputErr only added a message to the view, so exitCode still returned 0 after a failed write and scripts checking $? treated a truncated or missing results file as success. Track the failure on the model and fail the run, matching the CLI, where a file error outranks everything else.
Owner
|
Thank you for this. The root-cause write-up was clear and accurate. #155 was fixed on Your test is better than the one on Closing this as superseded. Thanks again, and contributions are welcome on the other open issues. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
subenum -tuiexits 0 when the results file could not be written, while the CLI exits 1 in the same situation (Fixes #155). Scripts that launch the TUI and check$?treat a truncated or missing results file as success.Root cause
reportOutputErrrecorded the failure only as a message in the scan view.exitCodeconsultsscanView.failed(), which tracks scan errors alone, so an output-file error never reached the process exit code.Fix
Track the failure on the model (
outputErr) whenreportOutputErris called and return 1 fromexitCodewhen it is set. This mirrors the CLI, where a file error outranks "no changes".Testing
go test ./internal/tui/passes. The newTestOutputFileFailureSetsExitCodedrives a realfinalizeOutputfailure (a directory blocking the final rename), asserts exit code 1 and the on-screen message, and checks that a clean model still exits 0.gofmt -lclean.