Skip to content
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

test_stream fails because API responds with ip_address = None #201

Open
adamchalmers opened this issue May 30, 2023 · 0 comments
Open

test_stream fails because API responds with ip_address = None #201

adamchalmers opened this issue May 30, 2023 · 0 comments

Comments

@adamchalmers
Copy link
Contributor

adamchalmers commented May 30, 2023

Currently the kittycad.rs test test_stream is failing. Why? Because it's trying to deserialize ApiCallWithPrice, but it finds an empty string when it tries to deserialize an IP address.

Test failure

---- tests::test_stream stdout ----
thread 'tests::test_stream' panicked at 'Serde Error: 
 1 | ...T07:00:23.846Z","ip_address":"","status_code":500,"method":"G...
   |                                   ^ invalid IP address syntax at line 1 column 8482785
', kittycad/src/tests.rs:112:25
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The relevant field is defined in kittycad.rs:

    #[doc = "The ip address of the origin."]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub ip_address: Option<std::net::IpAddr>,

and comes from this definition in api-deux

    /// The ip address of the origin.
    #[serde(default)]
    pub ip_address: crate::db::ipaddr::IpAddr,

Note that crate::db::ipaddr::IpAddr is a newtype around Option<std::net::IpAddr>, so kittycad.rs should know it can always be None and should deserialize the empty string into None.

This will require tweaking the Rust that openapitor outputs for openAPI fields like this, so, let's examine the OpenAPI spec for that field. It is:

          "ip_address": {
            "default": "",
            "description": "The ip address of the origin.",
            "format": "ip",
            "title": "String",
            "type": "string"
          },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant