MCPcopy Create free account
hub / github.com/PostHog/duckgres / RedactErrorForLog

Function RedactErrorForLog

server/usersecrets/redact.go:66–74  ·  view source on GitHub ↗

RedactErrorForLog returns an error message safe to log/store alongside query. When query carries CREATE SECRET DDL anywhere (head or a later top-level statement), the engine's error text may echo the secret literal, so the whole message is replaced with a fixed placeholder. Over-redaction only costs

(query, errMsg string)

Source from the content-addressed store, hash-verified

64// also emits an error: RedactForLog scrubs the query attribute, RedactErrorForLog
65// scrubs the error attribute.
66func RedactErrorForLog(query, errMsg string) string {
67 if errMsg == "" {
68 return errMsg
69 }
70 if queryHasCreateSecret(query) {
71 return redactedErrorPlaceholder
72 }
73 return errMsg
74}
75
76// queryHasCreateSecret reports whether query contains a CREATE SECRET at its
77// head or in any top-level statement. It shares the tokenizer with RedactForLog

Callers 5

registerImpersonateAPIFunction · 0.92
logQueryFinishedMethod · 0.92
logQueryErrorMethod · 0.92
logQueryMethod · 0.92
TestRedactErrorForLogFunction · 0.85

Calls 1

queryHasCreateSecretFunction · 0.85

Tested by 1

TestRedactErrorForLogFunction · 0.68