Skip to content

Emit a leaner stack_trace field (emit frames, not the message) - #1675

Draft
samikshya-db wants to merge 1 commit into
mainfrom
strip-pii-telemetry-stack-trace
Draft

Emit a leaner stack_trace field (emit frames, not the message)#1675
samikshya-db wants to merge 1 commit into
mainfrom
strip-pii-telemetry-stack-trace

Conversation

@samikshya-db

Copy link
Copy Markdown
Collaborator

Description

The telemetry stack_trace error field was populated with the exception message (reason), which despite the field name is not a stack trace at all. Exception messages in the driver routinely embed user data — SQL text, hostnames, literal filter values — so error telemetry could leak PII.

This change populates the field with the exception's actual stack frames (class.method(File:line)) via a new TelemetryHelper.formatStackTrace(Throwable), which are PII-free by construction. exportFailureLog now takes the Throwable, and each driver exception passes this so the captured throw-site frames are recorded. Frames are capped at 100. error_name/sqlState and all error codes are unchanged.

Affected exceptions: DatabricksSQLException, DatabricksDriverException, DatabricksTimeoutException, DatabricksTransactionException, DatabricksBatchUpdateException.

Testing

  • Added TelemetryHelperTest#testFormatStackTraceIncludesFramesButNotMessage, which asserts the formatted field contains code-location frames and never contains the exception message (including a sample PII string).
  • Added testFormatStackTraceWithNullReturnsNull.
  • Updated existing exportFailureLog test call sites to pass a Throwable.

Note: I was unable to run mvn test locally (no Maven in the dev environment); please rely on CI to run the suite.

Telemetry Errors

  • Not applicable — this PR does not add or change a telemetry-visible error.
  • Applicable — the error uses DatabricksDriverErrorCode where appropriate, and any
    new code is uniquely numbered and tested.
  • Applicable — its driver/server/user classification is linked, or maintainer help is
    requested because the author cannot access the classification.

Additional Notes to the Reviewer

No error names or numeric codes are added or changed — only the content of the existing stack_trace field changes (real frames instead of the message string). No telemetry taxonomy/dashboard classification update is required. Any downstream consumer that parsed the message text out of stack_trace should be aware it now contains stack frames.

Tradeoff: the human-readable exception message is no longer present in telemetry; error_name + sqlState + the stack frames carry the debugging signal.

NO_CHANGELOG=true

The telemetry stack_trace error field was populated with the exception
message (reason), which routinely embeds user data — SQL text, hostnames,
literal filter values — so error telemetry could leak PII.

Populate the field with the exception's actual stack frames instead
(class, method, file, line via a new TelemetryHelper.formatStackTrace),
which are PII-free by construction. exportFailureLog now takes the
Throwable, and each driver exception passes `this` so the captured
throw-site frames are recorded. error_name/sqlState are unchanged.

Add tests asserting the field contains frames and never the message.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: samikshya-chand_data <samikshya.chand@databricks.com>
@samikshya-db samikshya-db changed the title Strip PII from telemetry stack_trace field (emit frames, not the message) Emit a leaner stack_trace field (emit frames, not the message) Sep 4, 2026
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