-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON serialization error panics with PostgreSQL #2730
Comments
@abonander Is this something you would consider for the next breaking release? I can try taking this on. So far I tried making |
Yep, we've started putting together 0.8.0 so now is the time to do it! The infallibility requirement has bitten us in a few other places as well (#3053). I like the idea of storing the error internally until |
I've finally gotten around to finishing up my PR. |
Bug Description
When using
sqlx::Json
insqlx::query!
, if serializing the value fails, it panics withThe line where this happens is:
sqlx/sqlx-postgres/src/types/json.rs
Lines 74 to 75 in d0fbe7f
Not sure how to fix this without a breaking change because
Encode::encode_by_ref
returnsIsNull
and not aResult
of some kind. I would still argue that this shouldn't panic though.Minimal Reproduction
I created a small reproducer here: https://github.com/FSMaxB/sqlx-serialization-panic-reproducer
This is the same reproducer but without the full project setup.
I chose
#[serde(skip_serializing)]
to provoke the serialization error in this example, but it could also have been any other serialization error.Info
0.7.1
migrate
json
macros
postgres
runtime-tokio-rustls
Linux 6.4.12-200.fc38.x86_64 x86_64
rustc --version
:rustc 1.72.0 (5680fa18f 2023-08-23)
The text was updated successfully, but these errors were encountered: