Repository navigation
fix: save Postgres state for apps without a partition key - #949
Open
sangkyoonnam wants to merge 1 commit into
Open
sangkyoonnam wants to merge 1 commit into
sangkyoonnam wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 of 7 tasks
This branch has not been deployed
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.
The Postgres persisters now save state when the application has no partition key. Today an app built without
with_identifiers(partition_key=...)fails on its first step with either persister.ApplicationBuilderleavespartition_keyasNone, andPostgreSQLPersister.saveandAsyncPostgreSQLPersister.savepass it through as SQL NULL.partition_keyis part of the primary key, so the insert fails. On main, an app withinitialize_from(persister, ...)andwith_state_persister(persister)and no partition key raisespsycopg2.errors.NotNullViolation: null value in column "partition_key"onstep(), andasyncpg.exceptions.NotNullViolationErroronastep().loadalready mapsNonetoPARTITION_KEY_DEFAULT(""), and the SQLite persisters do the same insave, so this alignssavewith both. Forking from such an app, or spawningMapStatessub-applications that inherit itsNonekey, hit the same error and work with this change. I noted this in my #786 review, where the journal tables have the same issue.Changes
PostgreSQLPersister.saveandAsyncPostgreSQLPersister.savemap aNonepartition key toPARTITION_KEY_DEFAULT, the same wayloaddoes, and annotate it asOptional[str].How I tested this
partition_key=None. Both fail on main with the not-null error and pass here.postgres:15container withBURR_CI_INTEGRATION_TESTS=true: 13 passed. The app-level repro above steps without error on both persisters with this change.pytest tests --ignore=tests/integrations/persisters/test_postgresql.py --ignore=tests/integrations/test_bip0042_bedrock.py: 680 passed, 4 skipped.pre-commit runon the changed files passes.Notes
list_app_ids(None)on the Postgres persisters still matches nothing, while SQLite mapsNoneto""there too. fix: list each app once in SQL persister list_app_ids, newest save first #942 changes the same function, so I'll follow up once it lands rather than conflict with it.Checklist