You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(postgrest): reject list and map arguments in an rpc head() - #2276
rpc(...).head() now throws an ArgumentError for a list or map argument instead of sending {1,2}, which a json parameter rejects. A query parameter cannot say whether a list is an int[] or a jsonb, and head() has no body to fall back to.
Linear: SDK-3337
postgrestArgumentsFitQuery treats a list or map (not Uint8List) as not fitting a query, so rpc(get: true) and head() share one check.
The array literal and map encoding tests that went through head() now go through filters, the only path that still sends them in a query.
MIGRATION.md lists the new head() rejection.
Summary by CodeRabbit
Bug Fixes
RPC calls now use GET when their arguments can be represented safely as query parameters; other calls use POST.
HEAD function calls now reject null, list, and map arguments, as well as arguments that conflict with options or resemble filters. Byte-array arguments remain supported.
Documentation
Clarified which arguments are supported for HEAD function calls and when invalid arguments cause an ArgumentError.
No actionable comments were generated in the recent review.
Walkthrough
RPC query eligibility now rejects list and map arguments, while allowing byte arrays. RPC tests cover HEAD rejection and GET-to-POST routing. Typed RPC generation excludes array, JSON, and unknown argument types from GET methods.
Changes: RPC argument routing
Layer / File(s)
Summary
Argument eligibility and serialization packages/postgrest/lib/src/postgrest_filter.dart, packages/postgrest/lib/src/postgrest_transform_builder.dart, packages/postgrest/lib/src/postgrest_typed_transform_builder.dart, MIGRATION.md, packages/postgrest/test/filter_escape_test.dart
The query-eligibility check rejects null, list, and map values, allows Uint8List, and checks other rendered values for filter syntax. HEAD guidance and tests cover the argument restrictions and array serialization.
RPC documentation and tests cover POST fallback for list and map arguments, byte-array query parameters, and non-finite values in POST bodies. Read-only RPC tests keep row filters in the query string when list arguments use a POST body.
The generator excludes JSON, unknown, and array argument types from query parameters. The README and generated golden reflect the GET-method restrictions.
sequenceDiagram
participant Caller
participant PostgrestRpcBuilder
participant postgrestArgumentsFitQuery
participant HTTPRequest
Caller->>PostgrestRpcBuilder: Call rpc with arguments
PostgrestRpcBuilder->>postgrestArgumentsFitQuery: Check query eligibility
postgrestArgumentsFitQuery-->>PostgrestRpcBuilder: Return eligibility result
PostgrestRpcBuilder->>HTTPRequest: Send GET for eligible arguments or POST with JSON body otherwise
Loading
Possibly related issues
supabase/supabase-flutter#2272: The change rejects list and map arguments as query parameters, addressing that part of the issue. The issue’s separate not. filter case is not addressed.
Possibly related PRs
supabase/supabase-flutter#2026: Both changes define which RPC arguments are accepted by head(); this change extends the checks to list and map arguments.
supabase/supabase-flutter#2152: Both changes use postgrestArgumentsFitQuery to determine whether rpc(get: true) uses GET or POST.
Suggested reviewers:franklyn-r-silva
Merge Risk: Minimal · up to f2d09
This change makes rpc head() reject list and map arguments with an ArgumentError instead of sending ambiguous query parameters. The behavior is documented and tested. No merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: rpc head() now rejects list and map arguments with ArgumentError. The raw summary confirms this: postgrestArgumentsFitQuery rejects list and map values, and head() doc…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: rpc head() now rejects list and map arguments with ArgumentError. The raw summary confirms this: postgrestArgumentsFitQuery rejects list and map values, and head() documentation and error messages describe this behavior. The title is specific, concise, and matches the stated objective of making rpc(...).head() throw for list or map arguments.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
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
postgrestThis issue or pull request is related to postgrest
1 participant
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.
rpc(...).head()now throws anArgumentErrorfor a list or map argument instead of sending{1,2}, which ajsonparameter rejects. A query parameter cannot say whether a list is anint[]or ajsonb, andhead()has no body to fall back to.Linear: SDK-3337
postgrestArgumentsFitQuerytreats a list or map (notUint8List) as not fitting a query, sorpc(get: true)andhead()share one check.head()now go through filters, the only path that still sends them in a query.head()rejection.Summary by CodeRabbit
HEADfunction calls now reject null, list, and map arguments, as well as arguments that conflict with options or resemble filters. Byte-array arguments remain supported.HEADfunction calls and when invalid arguments cause anArgumentError.