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

Rust client fail to parse UiNodeAttributes #381

Open
3 of 5 tasks
chunleng opened this issue Oct 28, 2024 · 1 comment
Open
3 of 5 tasks

Rust client fail to parse UiNodeAttributes #381

chunleng opened this issue Oct 28, 2024 · 1 comment
Labels
bug Something is not working.

Comments

@chunleng
Copy link

chunleng commented Oct 28, 2024

Preflight checklist

Ory Network Project

No response

Describe the bug

While using create_native_registration_flow, I ran into the following bug:

called `Result::unwrap()` on an `Err` value: Serde(Error("missing field `node_type`", line: 1, column: 508))

It seems to have occurred once before in #325 and appeared again

Reproducing the bug

Run the following code:

use ory_client::apis::{
    configuration::Configuration, frontend_api::create_native_registration_flow,
};

#[tokio::main]
async fn main() {
    create_native_registration_flow(
        &Configuration {
            base_path: "http://localhost:4433".to_string(),
            ..Default::default()
        },
        None,
        None,
    )
    .await
    .unwrap();
}

Relevant log output

called `Result::unwrap()` on an `Err` value: Serde(Error("missing field `node_type`", line: 1, column: 508))

Relevant configuration

No response

Version

Kratos 1.3.0

On which operating system are you observing this issue?

macOS

In which environment are you deploying?

Docker Compose

Additional Context

docker image: oryd/kratos:v1.3.0
cargo:

ory-client = { git = "https://github.com/ory/client-rust", tag = "v1.14.5" }
@chunleng chunleng added the bug Something is not working. label Oct 28, 2024
@chunleng
Copy link
Author

Did a little testing locally and found out that the autogenerator might be a little off:

According to serde library: https://serde.rs/enum-representations.html#internally-tagged
When using #[serde(tag = "node_type")], the relevant field should not appear in the enum item's struct, however, the
autogenerator seems to have included node_type in the item, causing the deserialize to fail

// https://github.com/ory/client-rust/blob/10027729688da0967e45cf7d7e1b8a1ec5ea8173/src/models/ui_node_attributes.rs#L16
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "node_type")]
pub enum UiNodeAttributes {
    #[serde(rename="input")]
    Input(Box<models::UiNodeInputAttributes>),
    ...
}

// https://github.com/ory/client-rust/blob/10027729688da0967e45cf7d7e1b8a1ec5ea8173/src/models/ui_node_input_attributes.rs#L16
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct UiNodeInputAttributes {
    ...
    /// NodeType represents this node's types. It is a mirror of `node.type` and is primarily used to allow compatibility with OpenAPI 3.0.  In this struct it technically always is \"input\". text Text input Input img Image a Anchor script Script
    #[serde(rename = "node_type")]
    pub node_type: NodeTypeEnum,
    ...
}

One method to resolve is to remove node_type field from the struct of UiNodeXXXAttributes (e.g. UiNodeInputAttributes, etc.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working.
Projects
None yet
Development

No branches or pull requests

1 participant