Repository navigation
fix: resolve the outbox table through search_path in validate_schema - #232
Merged
Merged
Conversation
Benchmark gate✅ gate passed
Gated (fails the build): |
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.
For 0.15.1, no issue:
validate_schema()now checks the table the app actually uses when an unqualified table name resolves through a latersearch_pathentry.The bug
Take a
search_pathofapp, publicwhere theappschema exists but the outbox table is inpublic. The app reads and writespublic.outbox. The CHECK-constraint, partial-index and autovacuum probes looked only incurrent_schema(), which isapp, so validation failed on a correct table:outbox_autovacuum_ddl()was applied;The Alembic diff wasn't affected: SQLAlchemy reflects an unqualified table through
pg_table_is_visible, which follows the wholesearch_path.The fix
validate_schema()asks Postgres once where the name lands:to_regclass(format('%I', :table)), joined topg_namespace.format('%I')quotes the name the way an unqualified identifier in the app's SQL is resolved, so mixed-case names work too. The resolved schema is passed to every probe and to the Alembic comparison. The DLQ table is resolved separately.schemaskips the lookup.None, so the probes keep the oldcurrent_schema()fallback and the Alembic diff still reports "does not exist".Tests
test_validate_schema_finds_a_table_through_a_later_search_path_entrybuilds that layout: an empty schema first on thesearch_path, the outbox and DLQ tables plus autovacuum tuning inpublic. Before the fix it failed with the missing CHECK and the untuned autovacuum. The unit tests that call the probes directly now pass the schema.Verification
ruffandtyare clean.validate_schema()call, which runs at startup or in a health check. No effect on publish or fetch.