ref: Add sanitizeSqlQueryWithSummary helper and DB bugbot rule - #24244
Merged
Conversation
s1gr1d
requested review from
mydea and
nicohrubec
and removed request for
a team
September 9, 2026 12:44
Contributor
size-limit report 📦
|
Lms24
approved these changes
Sep 9, 2026
| - `consoleSandbox(() => { console.warn(...) })` for intentional user-facing warnings (e.g. init-time misconfiguration messages). The `consoleSandbox` wrapper prevents the SDK's own console instrumentation from intercepting the call. Bare `console.*` calls outside very early init paths (e.g. before the logger is available) should be flagged. | ||
| - Flag `url.full`, `url.query`, `http.target` or `request.query_string` being set from a URL that isn't filtered. Wrap the value in `filterCollectedUrl()` (or `filterCollectedUrlQuery()` for a bare query string), passing the `client` if one is in scope, so `dataCollection.urlQueryParams` applies. Values that can't contain a query (a bare pathname, a queue URL) are fine. The `sdk/no-unfiltered-url-attributes` lint rule catches direct attribute writes, so look for what it can't: URLs passed through a helper or variable first, deprecated aliases set next to a filtered attribute, and URLs on breadcrumbs or events instead of spans. | ||
| - Flag span names built from a raw URL. Names follow `METHOD scheme://host/path` and must never contain a query string, so they need `stripUrlQueryAndFragment()`, not `filterCollectedUrl()`. | ||
| - Flag a SQL statement reaching telemetry unsanitized: `db.query.text`, `db.query.summary`, DB span names and breadcrumbs carrying a statement all have to come from `sanitizeSqlQuery()` / `sanitizeSqlQueryWithSummary()` (`@sentry/server-utils`). Inline literals are user data, and OTel only allows collecting query text once they are replaced with `?` — deliberately not gated on `dataCollection.databaseQueryData`, which does not cover query text. Sanitize each statement before it is joined into a batch, pass the `'mysql'` dialect for mysql/mysql2/MariaDB (there `"…"` quotes a value, not an identifier), and prefer `sanitizeSqlQueryWithSummary()`, which omits both attributes for an empty statement instead of reporting `'Unknown SQL Query'`. The sinks that get missed are the breadcrumb next to an already-sanitized span and the span name used when span streaming is off. Redis command text is not SQL and has its own redaction path. |
Member
There was a problem hiding this comment.
The sinks that get missed are the breadcrumb next to an already-sanitized span
sorry what does this mean? 😅 As-in: breadcrumbs contain unsanitized query text?
Member
Author
There was a problem hiding this comment.
I used a write-for-agent skill but I agree this is too much "claudism" and not readable anymore for us 😅 I think this means that the breadcrumbs don't need the summary, just the query text. I'm gonna rewrite that
s1gr1d
added this pull request to stack #24251
September 9, 2026 13:33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up for #24089