Bug Report: connection-setting errors log the setting text verbatim, bypassing --sanitize-log-messages
Overview of the Issue
vttablet's connection-setting validation embeds the full text of a rejected setting in the error it returns. On main:
planbuilder/sql_mode.go:connection setting must not contain a subquery: %s(rejectSettingSubqueries, #21139),failed to parse connection setting: %sandconnection setting is not a SET statement: %s(ValidateSettingsSQLMode), andnon-constant sql_mode value in connection settings: %splanbuilder/plan.go:[BUG]: failed to parse system setting: %s(BuildSettingQuery)
None of these is a *sqlerror.SQLError, so TabletServer.convertAndLogError logs err.Error() as is and passes only the separately appended request query through queryAsString(..., tsv.Config().SanitizeLogMessages, ...). With --sanitize-log-messages, the literals of a rejected setting, such as those in a subquery rejected under strict table ACL, still reach the tablet log (at INFO for these INVALID_ARGUMENT errors).
The same messages are in the release-24.0 and release-23.0 backports of #21139 (#21220, #21219), where rejectSettingSubqueries lives in planbuilder/plan.go. Copilot raised it on #21219: https://github.com/vitessio/vitess/pull/21219#discussion_r4124196271
A possible direction: stop echoing the setting in these errors (identify it by position instead), or redact it when --sanitize-log-messages is set, and add a test that runs a rejected setting through convertAndLogError with SanitizeLogMessages and asserts its literal is absent from the log.
Reproduction Steps
- Run vttablet with
--queryserver-config-strict-table-acland--sanitize-log-messages. - Send a reservation (for example
ReserveBeginExecute) whose pre-query isset @@sql_select_limit = (select count(*) from t where secret = 'hunter2'). - The request is rejected with
connection setting must not contain a subquery: ..., and the tablet log line contains'hunter2'.
Binary Version
main, and the release-24.0 and release-23.0 backports of #21139.
Operating System and Environment details
Not environment-specific.
Log Fragments
Not captured; the message format is determined by the code paths above.
Source: vitessio/vitess