Skip to content

fix: return text report output failures to command callers - #93

Open
DivyamTalwar wants to merge 1 commit into
pgrundev:mainfrom
DivyamTalwar:fix/preserve-report-write-errors
Open

DivyamTalwar wants to merge 1 commit into
pgrundev:mainfrom
DivyamTalwar:fix/preserve-report-write-errors

Conversation

@DivyamTalwar

Copy link
Copy Markdown
Contributor

What and why

Closes #92.

Return final write errors from DiffReport and AdvisorReport, including io.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.

  • Actual SQLite-backed Cobra diff regression fails on unchanged upstream production code at 9e41414abed05f10ad7ff2fbe7662a5172f151f7: output failure returns nil.
  • Advisor negative control retains only backend test instrumentation and swallows the renderer result; the actual command regression fails until error propagation is restored.
  • go test -race ./internal/render ./cmd/pgbot -run 'TestTextReports_|TestDiffCommand_ReturnsOutputError|TestAdviseCommand_ReturnsOutputError' -count=20: passed.
  • Complete render/CLI race suites passed.
  • bash scripts/gate.sh: passed on committed HEAD, including pinned lint, tests and all six release-target builds.
  • go test -race ./...: passed; formatting and git diff --check clean.

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

  • Committed-HEAD gate and full race suite pass.
  • Read-only, privacy and deterministic findings unchanged.
  • No new finding or model field; catalog and schema unchanged.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text diff and advisor commands ignore failed output writes

1 participant