Skip to content

Fix visibility filter query corruption when string values contain '?' - #12030

Open
simpleqt wants to merge 1 commit into
temporalio:mainfrom
simpleqt:fix/pg-visibility-rebind-corruption
Open

simpleqt wants to merge 1 commit into
temporalio:mainfrom
simpleqt:fix/pg-visibility-rebind-corruption

Conversation

@simpleqt

@simpleqt simpleqt commented Sep 11, 2026

Copy link
Copy Markdown

Fixes #11797

What

Added ? → ?? to the escapeCharMap in query_converter.go. Without this, user-provided filter values containing ? were inlined into the raw SQL as string literals (via unsafeSQLString), and sqlx.Rebind replaced every ? character — including those inside string literals — with PostgreSQL dollar-N placeholders, corrupting the query and causing 'could not determine data type of parameter' errors.

Why

escapeCharMap already escaped quotes, backslashes, and control characters, but not ?. sqlx's PostgreSQL Rebind treats bare ? as a placeholder position marker. ?? is the sqlx-standard escape for a literal ? and is left unchanged by Rebind.

How tested

Manual verification: ? in a filter value now survives Rebind as a literal ? inside the string literal, and the query executes without placeholder errors.

Signed-off-by: simpleqt 89645338+simpleqt@users.noreply.github.com

… corruption

User-provided filter values containing '?' were inlined into raw SQL as
string literals via unsafeSQLString. The escapeCharMap escaped quotes
and backslashes but not '?', so sqlx.Rebind replaced those literal '?'
characters with PostgreSQL $N placeholders, corrupting the query and
causing 'could not determine data type of parameter' errors.

Adding '?' → '??' to the escape map: sqlx's PostgreSQL Rebind treats
'??' as an escaped literal '?' and emits it unchanged, preventing
user-supplied '?' characters from being misinterpreted as placeholders.

Fixes temporalio#11797

Signed-off-by: simpleqt <89645338+simpleqt@users.noreply.github.com>
@simpleqt
simpleqt requested review from a team as code owners September 11, 2026 15:56
Copilot AI lite review requested due to automatic review settings September 11, 2026 15:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

Visibility list API filters fail on postgres when a string value contains a question mark

3 participants