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)
| 64 | // also emits an error: RedactForLog scrubs the query attribute, RedactErrorForLog |
| 65 | // scrubs the error attribute. |
| 66 | func 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 |