Skip to content

fix(spanner): avoid writing bound parameter values to SpannerException at FINEST logging - #15275

Merged
sakthivelmanii merged 1 commit into
mainfrom
fix/spanner-finest-param-leak
Dec 1, 2026
Merged

sakthivelmanii merged 1 commit into
mainfrom
fix/spanner-finest-param-leak

Conversation

@sakthivelmanii

Copy link
Copy Markdown
Contributor

Problem Statement

  • When FINEST logging is enabled for streaming queries in the Cloud Spanner Java client, bound query parameter values and query options are appended to the thrown SpannerException message.
  • Because the mutated exception is returned to callers and recorded by tracing integrations, sensitive bound parameter values can propagate beyond the FINEST log record into application error logs, retry logs, and OpenTelemetry/OpenCensus trace spans.

Solution

  • Always attach only the SQL text (without bound parameter values or query options) to SpannerException when a streaming query fails, regardless of the configured log level.
  • Emit the full statement including bound parameters strictly inside the FINEST log record message so opt-in FINEST diagnostics remain available without leaking parameter values into thrown exceptions or trace spans.

@sakthivelmanii
sakthivelmanii requested review from a team as code owners November 29, 2026 04:44

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request ensures that sensitive bound parameter values in SQL statements are never leaked through thrown SpannerExceptions, even when the logging level is set to FINEST. Instead, parameter values are strictly emitted within the FINEST log records. The changes include updates to GrpcStreamIterator, a new CapturingLogHandler test utility, and comprehensive unit tests verifying that parameters do not leak to exceptions, OpenTelemetry/OpenCensus spans, or retry logs. There are no review comments, and I have no feedback to provide.

@olavloite olavloite self-assigned this Dec 1, 2026
…n at FINEST logging

- When `FINEST` logging is enabled for streaming queries in the Cloud Spanner Java client, bound query parameter values and query options are appended to the thrown `SpannerException` message.
- Because the mutated exception is returned to callers and recorded by tracing integrations, sensitive bound parameter values can propagate beyond the `FINEST` log record into application error logs, retry logs, and OpenTelemetry/OpenCensus trace spans.

- Always attach only the SQL text (without bound parameter values or query options) to `SpannerException` when a streaming query fails, regardless of the configured log level.
- Emit the full statement including bound parameters strictly inside the `FINEST` log record message so opt-in `FINEST` diagnostics remain available without leaking parameter values into thrown exceptions or trace spans.
@sakthivelmanii
sakthivelmanii force-pushed the fix/spanner-finest-param-leak branch from fb47890 to c907fc5 Compare December 1, 2026 14:37
@sakthivelmanii
sakthivelmanii enabled auto-merge (squash) December 1, 2026 14:39
@sakthivelmanii
sakthivelmanii merged commit ebdb08d into main Dec 1, 2026
198 of 199 checks passed
@sakthivelmanii
sakthivelmanii deleted the fix/spanner-finest-param-leak branch December 1, 2026 15:04
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.

2 participants