#21253·vitess

Bug Report: connection-setting errors log the setting text verbatim, bypassing --sanitize-log-messages

Author: mattlordCreated Sep 28, 2026Updated Sep 30, 2026
LabelsType: BugComponent: Query ServingComponent: VTTablet

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: %s and connection setting is not a SET statement: %s (ValidateSettingsSQLMode), and non-constant sql_mode value in connection settings: %s
  • planbuilder/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

  1. Run vttablet with --queryserver-config-strict-table-acl and --sanitize-log-messages.
  2. Send a reservation (for example ReserveBeginExecute) whose pre-query is set @@sql_select_limit = (select count(*) from t where secret = 'hunter2').
  3. 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.