fix: return text report output failures to command callers - #93
Open
DivyamTalwar wants to merge 1 commit into
Open
DivyamTalwar wants to merge 1 commit into
DivyamTalwar wants to merge 1 commit into
Conversation
The diff and advisor text renderers ignored their final write result, so a broken destination could produce a successful command with missing output. Return the original error, reject silent short writes, and propagate the result through the actual Cobra handlers. Tests exercise both command paths, real SQLite-backed diff history, large and empty reports, reset-only output and successful output preservation. The advisor collection seam supplies only the backend result. The original diff command and a swallowed-error advisor control fail; focused tests pass 20 race repetitions and full render/CLI race suites pass. No SQL, dependencies or JSON contract changes. The separate reset branch in PR pgrundev#64 must propagate this same writer error when the changes are combined.
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.
What and why
Closes #92.
Return final write errors from
DiffReportandAdvisorReport, includingio.ErrShortWrite, and propagate them through the actual Cobra handlers. Previously these paths could report success despite an incomplete or rejected text report.Cobra output routing allows the regression to exercise the real command. The advisor seam supplies only backend results; rendering and error propagation remain real. Successful report bytes and the JSON contract are unchanged.
Verification
Verified commit:
faa9c8d0c4fc310af7cbab46ea8dcc902e9d8937.9e41414abed05f10ad7ff2fbe7662a5172f151f7: output failure returns nil.go test -race ./internal/render ./cmd/pgbot -run 'TestTextReports_|TestDiffCommand_ReturnsOutputError|TestAdviseCommand_ReturnsOutputError' -count=20: passed.bash scripts/gate.sh: passed on committed HEAD, including pinned lint, tests and all six release-target builds.go test -race ./...: passed; formatting andgit diff --checkclean.Scope and risk
No database queries, dependencies, schema migrations or JSON fields change. Tests exercise actual renderers, real stored-history diff routing and the actual advisor command after its backend seam. No live PostgreSQL operation is claimed. PR #64 touches the reset branch in this renderer and needs compatible error-return integration when combined; this PR intentionally does not include its separate reset fix. Revert the commit to restore prior error handling.
Checklist