fix: correct PGOPTIONS parsing and search_path handling#768
Closed
b3b wants to merge 1 commit intosupabase:mainfrom
Closed
fix: correct PGOPTIONS parsing and search_path handling#768b3b wants to merge 1 commit intosupabase:mainfrom
b3b wants to merge 1 commit intosupabase:mainfrom
Conversation
Replaces the old URI.decode_query-based parser with a new StartupOptions tokenizer that accurately parses the `options` field from PostgreSQL startup packets. - Prevents forwarding of extra options after `--search_path` - Supports `--key=value,` `-c key=value` and `-ckey=value` forms
Member
|
Incorporated this in #858 too, thank you! |
v0idpwn
added a commit
that referenced
this pull request
Feb 11, 2026
- Fixes #854, a bug reported recently (a change in a Go library caused it to start hitting this bug) - Properly parses the options field in the startup message -- it was just off since forever. This was implemented in #768 by @b3b but I decided to give it a stab. - Ensures we handle search_path correctly - `log_level` is set on ClientHandler, but that's not very useful since currently it can only be used to **decrease** the log level, not increase (consequence of how process log level works in elixir) - Other options continue being ignored, they are just parsed properly
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: improves PGOPTIONS parsing to correctly handle both
--key=valueand-c key=valuesyntax, prevent malformed tokens, and avoid leaking unintended parameters to Postgres.What is the current behavior?
Supavisor currently parses PGOPTIONS using
URI.decode_query, but PostgreSQL does not URI-encode connection options they are space-separated key=value pairs.This causes several issues:
-c key=valuesyntax is not supported--search_pathis first, following options are passed throughNote
In this case, Supavisor repeatedly tries to reconnect and floods the logs with:
[error] DbHandler: Error auth response ["SFATAL", "VFATAL", "C42601", "Minvalid command-line argument for server process: --search_path=custom", "HTry \"postgres --help\" for more information.", "Fpostgres.c", "L3931", "Rprocess_postgres_switches"]Related issues
What is the new behavior?
Additional context
Integration tests for this behavior are included in #770