Add more context to SendBatch error #2490
Open
makalaaneesh wants to merge 1 commit intojackc:masterfrom
Open
Conversation
Owner
|
I'm wary about including the entire SQL string in an error. We've had complaints before about error messages potentially leaking sensitive information into logs. I'd prefer to avoid adding any new leak vectors. Also, SQL text can be very large and I'm not sure we want to put the whole thing in error text. I am still interested in improving this situation though. The "failed to prepare statement" part of the message is interesting. That, or something like it that made clear that the error occurred while preparing the batch is a good idea. |
Author
|
That's fair. How about returning a specific error struct (something like
That way,
What do you think? |
Owner
|
That sounds like a reasonable approach. |
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.
Hi @jackc, this is a follow-up to #872 (comment)
If there is an error while preparing statements in a batch (syntax error for example),
As fixing 1 is tricky as pointed out in the #872,
This PR just adds a bit of context to the error (similar to #1441 )
Code to test:
Before:
panic: statement 1 failed: ERROR: syntax error at or near "VALS" (SQLSTATE 42601)After:
panic: statement 1 failed: failed to prepare statement: INSERT INTO batch_test (name, value) VALS ($1, $2): ERROR: syntax error at or near "VALS" (SQLSTATE 42601)