Skip to content

Show the valid values in the target_session_attrs error - #1396

Open
spicysharkco wants to merge 2 commits into
MagicStack:masterfrom
spicysharkco:fix-target-session-attrs-message
Open

spicysharkco wants to merge 2 commits into
MagicStack:masterfrom
spicysharkco:fix-target-session-attrs-message

Conversation

@spicysharkco

@spicysharkco spicysharkco commented Oct 16, 2026 •

Copy link
Copy Markdown

An invalid target_session_attrs (for example ?target_session_attrs=bogus in the DSN) raises ClientConfigurationError with this message:

target_session_attrs is expected to be one of <built-in method values of mappingproxy object at 0x...>, got 'bogus'

The format call passes SessionAttribute.__members__.values without calling it. The change lists the enum values instead, so the message reads ... one of ['any', 'primary', 'standby', 'prefer-standby', 'read-write', 'read-only'], got 'bogus'.

Tested with a new target_session_attrs_invalid row in TestConnectParams, which checks the whole message, values in order, and fails without the change and passes with it. flake8 is clean.

The message formatted the unbound SessionAttribute.__members__.values
method, so it printed "<built-in method values of mappingproxy object>"
instead of the accepted values.
The pattern matched any list that starts with any and ends with
read-only, so a message that dropped or reordered values passed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant