Skip to content

fix(postgrest): reject list and map arguments in an rpc head() - #2276

Merged
spydon merged 2 commits into
mainfrom
lukasklingsbo/sdk-3337-rpc-head-rejects-list-arguments
Dec 4, 2026
Merged

spydon merged 2 commits into
mainfrom
lukasklingsbo/sdk-3337-rpc-head-rejects-list-arguments

Conversation

@spydon

@spydon spydon commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added the postgrest This issue or pull request is related to postgrest label Dec 3, 2026
@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

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 request behavior
packages/postgrest/lib/src/postgrest_rpc_builder.dart, packages/postgrest/lib/src/postgrest_rpc.dart, packages/postgrest/lib/src/postgrest_table_request.dart, packages/postgrest/test/transform_request_test.dart, packages/postgrest/test/typed_rpc_test.dart
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.
Typed RPC argument eligibility
packages/supabase_typegen/lib/src/dart_generator.dart, packages/supabase_typegen/README.md, packages/supabase_typegen/test/goldens/supabase_schema.dart
The generator excludes JSON, unknown, and array argument types from query parameters. The README and generated golden reflect the GET-method restrictions.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

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

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: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 3e1a7f0 and f2d096d.

Files selected for processing: 1

  • packages/postgrest/lib/src/postgrest_rpc_builder.dart

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@spydon
spydon force-pushed the lukasklingsbo/sdk-3337-rpc-head-rejects-list-arguments branch from e279e23 to 3e1a7f0 Compare December 3, 2026 17:03
@spydon
spydon force-pushed the lukasklingsbo/sdk-3337-rpc-head-rejects-list-arguments branch from 3e1a7f0 to f2d096d Compare December 4, 2026 09:32
@spydon
spydon merged commit ec2d1aa into main Dec 4, 2026
61 checks passed
@spydon
spydon deleted the lukasklingsbo/sdk-3337-rpc-head-rejects-list-arguments branch December 4, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

postgrest This issue or pull request is related to postgrest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant