Skip to content

[Snapshot] Prevent GetTables shadowing outer result slice#960

Open
kvch wants to merge 1 commit into
mainfrom
fix-shadowed-table-append
Open

[Snapshot] Prevent GetTables shadowing outer result slice#960
kvch wants to merge 1 commit into
mainfrom
fix-shadowed-table-append

Conversation

@kvch

@kvch kvch commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Description

Previously, Snapshot.GetTables() used the same name tables for both the outer result slice and the per-schema loop variable. Appends went to the shadowed per-schema slice and were discarded each iteration, so the function always returned the empty outer slice. This lead to broken diagnostics (snapshot error logs and the OTel span attribute).

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

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

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/xataio/pgstream/pkg/snapshot 75.90% (+8.43%) 👍

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/xataio/pgstream/pkg/snapshot/snapshot.go 28.00% (+28.00%) 25 7 (+7) 18 (-7) 🌟

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/pkg/snapshot/snapshot_test.go

@kvch kvch changed the title [Snapshot] Prevent GetTables shadowing outer result slice [Snapshot] Prevent GetTables shadowing outer result slice Jul 2, 2026
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.

1 participant