googleapis / googleapis/google-cloud-rust

prost_types::Value to wkt::Value conversion panics on NaN or infinity

Open Beginner friendly
#6,707 0 comments 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
Rust
Stars
955
Forks
144
Avg merge
1d 5h
Merged PRs (30d)
279

Description

Unconfirmed. This is the result of a search with Claude, may be a false positive.

In `src/gax-internal/src/prost.rs`, converting `prost_types::Value` to `wkt::Value` handles `Kind::NumberValue(v)`:

https://github.com/googleapis/google-cloud-rust/blob/f02b42c2ac5720334cd2b5335824bd4166264527/src/gax-internal/src/prost.rs#L169-L173

```rust
Kind::NumberValue(v) => {
let number =
serde_json::Number::from_f64(v).expect("JSON numbers cannot be NaN");
serde_json::Value::Number(number)
}
```

While JSON does not permit `NaN` or `Infinity`, protobuf binary encoding for `double` fields can carry `NaN`, `+Infinity`, and `-Infinity`.

When a gRPC response containing `NaN` or `Infinity` in a `google.protobuf.Value` field is received, `.expect()` panics and crashes the client. The function signature already returns `Result`, so an error should be returned instead.

Contributor guide

Open the contributing guide

Research direction

Start in src/gax-internal/src/prost.rs at the Kind::NumberValue conversion around lines 169–173, and inspect the surrounding Result and error-handling paths. Verify behavior for NaN, +Infinity, and -Infinity; done means these inputs return an error instead of panicking, with regression coverage for the conversion.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.