Repository navigation
fix(postgrest): serialize dictionary rpc query arguments as json - #1848
Closed
Kayvan-Zahiri wants to merge 1 commit into
Closed
Kayvan-Zahiri wants to merge 1 commit into
Kayvan-Zahiri wants to merge 1 commit into
Conversation
Contributor
Author
|
@olirice @silentworks — requesting review as CONTRIBUTING.md asks. This small fix follows issue #1847 and adds generated sync/async request-level coverage; 398 offline PostgREST tests and package mypy pass. Database integration tests have not been run. |
spydon
added a commit
that referenced
this pull request
Nov 2, 2026
…requests (#1899) ## What `rpc(..., get=True)` and `rpc(..., head=True)` send arguments in the query string. Dictionary arguments were passed through as-is, so httpx rendered them with Python's `str(dict)` (for example `{'enabled': True}`), which PostgREST cannot parse as `json`/`jsonb`. `rpc_query_param` now encodes dictionaries as compact JSON (`json.dumps(value, separators=(",", ":"))`). POST requests are unchanged, since their arguments are already sent as a JSON body. ## Tests Added `test_rpc_serializes_dictionary_arguments` (async and generated sync) using `MockTransport`. It checks GET, HEAD and POST with flat, nested and empty dictionaries, and verifies that string, list and scalar arguments keep their existing encoding. ## Credit Based on #1848 by Kayvan-Zahiri, brought onto current main and switched to compact JSON. This PR supersedes #1848. Closes #1847 Linear: SDK-2640 Co-authored-by: Kayvan Zahiri <[email protected]>
Contributor
|
Thanks for the fix! This has been superseded by #1899, which builds on your changes (with you credited as co-author) and is now merged. |
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.
What kind of change does this PR introduce?
Bug fix for PostgREST GET/HEAD RPC dictionary arguments.
What is the current behavior?
Closes #1847, filed before implementation as CONTRIBUTING.md requests.
rpc("example", {"options": {"enabled": True}}, get=True)sendsoptions={'enabled': True}: HTTPX stringifies the dictionary as Python text, which is invalid for a named PostgreSQL JSON/JSONB argument. HEAD has the same behavior. POST already serializes the argument correctly in its JSON body.What is the new behavior?
JSON-encode dictionaries in the shared RPC query-argument helper. Preserve the existing list/tuple PostgreSQL array-literal handling and leave raw JSON strings and other scalar arguments unchanged. No public symbols, dependencies or versions change.
The async-source request-level tests cover GET, HEAD and POST with a boolean dictionary, nested arrays/nulls and an empty dictionary. They also check pre-serialized JSON strings, array arguments and ordinary strings. Sync tests are regenerated with
make postgrest.build-sync, followed bymake ruffas AGENTS.md requires. Four async regression cases fail before the fix; five controls pass.Additional context
Validation with Python 3.12.12 and the unchanged frozen uv workspace:
make ruffandgit diff --check: pass.The offline run explicitly excludes the two database integration test files; full Docker/PostgREST integration, other workspace packages and the Python3.9–3.14/OS matrix were not run. New HTTP requests use MockTransport; no credentials or hosted calls were used. GNU sed was installed for the prescribed generator. Release-managed versions, changelogs and lockfile are unchanged. Developed with Codex assistance and reproduced locally.