Skip to content

Surface error even if we cannot parse ERROR lines in the output of restore#771

Merged
kvch merged 2 commits intomainfrom
fix-surface-restore-error
Mar 11, 2026
Merged

Surface error even if we cannot parse ERROR lines in the output of restore#771
kvch merged 2 commits intomainfrom
fix-surface-restore-error

Conversation

@kvch
Copy link
Collaborator

@kvch kvch commented Mar 11, 2026

Description

Fix RunPGRestore producing error restoring dump: %!w(<nil>) when the command fails with a non-zero exit code but the output contains no parseable ERROR lines. Now falls back to the exec error instead of wrapping nil.

Type of Change

Please select the relevant option(s):

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔧 Refactoring (no functional changes)
  • ⚡ Performance improvement
  • 🧪 Test coverage improvement
  • 🔨 Build/CI changes
  • 🧹 Code cleanup

Changes Made

  • Extract error-handling logic into buildRestoreError for testability and add tests covering all combinations of exec error and output parsing

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • All existing tests pass

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Code is well-commented
  • Documentation updated where necessary

Additional Notes

@github-actions
Copy link

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/xataio/pgstream/internal/postgres 32.31% (+1.27%) 👍

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/xataio/pgstream/internal/postgres/pg_restore.go 49.45% (+5.40%) 91 (+7) 45 (+8) 46 (-1) 👍

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/xataio/pgstream/internal/postgres/pg_restore_test.go

@kvch kvch merged commit 9888095 into main Mar 11, 2026
7 checks passed
@kvch kvch deleted the fix-surface-restore-error branch March 11, 2026 18:52
tsg pushed a commit that referenced this pull request Mar 11, 2026
…store (#771)

Fix `RunPGRestore` producing `error restoring dump: %!w(<nil>)` when the command fails with a non-zero exit code but the output contains no parseable ERROR lines. Now falls back to the exec error instead of wrapping nil.
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.

2 participants