Skip to content

Program panics when serde_json is built with arbitrary_precision feature #14

@RichardWGNR

Description

@RichardWGNR

Description

Program panics when serde_json is built with arbitrary_precision feature

thread 'actix-server worker 0' panicked at src\http_services\api\dashboard\summary.rs:11:14:
called `Result::unwrap()` on an `Err` value: Client(ClientError { message: "failed to parse JSON response from server", source: Some(reqwest::Error { kind: Decode, source: Error("invalid type: map, expected f64", line: 0, column: 0) }) })
stack backtrace:

To reproduce

  1. cargo.toml
[dependencies]
serde_json = { version = "1.0.117", features = ["arbitrary_precision"] }
prometheus-http-query = { version = "0.8.3" }
  1. Then try querying any metric via Client::query().await

Cause

  1. This is due to the way serde_json handles numeric values with “arbitrary_precision” feature.
  2. The current logic forces serde_json to cast the String type to Float64:
    #[serde(deserialize_with = "de::deserialize_f64")]

My opinion

This is a bug in the current crate.

I believe there is no need to convert String to F64, as that is the prerogative of those who really need it.

On the other hand, if contributors wish not to fix this, the correct operation of the crate with arbitrary_precision feature should be implemented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions