fix(postgrest): build a valid Prefer header in select() when none is set#1433
Open
spydon wants to merge 2 commits into
Open
fix(postgrest): build a valid Prefer header in select() when none is set#1433spydon wants to merge 2 commits into
spydon wants to merge 2 commits into
Conversation
PostgrestTransformBuilder.select() appended 'return=representation' to the existing Prefer value, but when no Prefer header was set yet (e.g. rpc(...).select()) it interpolated the null value and produced the malformed header 'nullreturn=representation'. Default the missing value to an empty string. Adds a regression test, and drops two redundant this. qualifiers left by an earlier rename.
grdsdev
approved these changes
Jun 17, 2026
…ment Compose the Prefer header from a list joined by commas instead of a conditional prepend followed by a second assignment.
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.
Stacked on #1432.
What
This came out of investigating
avoid-nullable-interpolation(PR scope: only the meaningful sites — most of that rule's 80 hits are cosmetictoString/log interpolation, so the rule stays disabled). One site turned out to be a real bug:PostgrestTransformBuilder.select()builds thePreferheader like:The second line runs unconditionally. When no
Preferheader is set yet,newHeaders['Prefer']isnulland the interpolation produces the malformed headernullreturn=representation.insert()/update()/delete()setPrefer = ''first, so their.select()is unaffected — butrpc(...).select()does not setPrefer, so it was sending the malformed header.Fix: default the missing value to an empty string (
${newHeaders['Prefer'] ?? ''}). No change whenPreferis already set.Also
rpc('empty-succ').select().head()now sendsPrefer: return=representation(fails before this fix withnullreturn=representation).this.qualifiers inpostgrest.dartleft over from an earlierurl -> requestUrlrename.Verification
dart analyzeclean (incl. infos);dcm analyze packages-> no issues found.Note:
avoid-nullable-interpolationitself remains disabled (the toString/log majority would still violate it).