Can't deserialize response: missing field `nodetype`
sg1fan opened this issue · comments
Preflight checklist
- I could not find a solution in the existing issues, docs, nor discussions.
- I agree to follow this project's Code of Conduct.
- I have read and am following this repository's Contribution Guidelines.
- This issue affects my Ory Cloud project.
- I have joined the Ory Community Slack.
- I am signed up to the Ory Security Patch Newsletter.
Describe the bug
initialize_self_service_registration_flow_without_browser
is panicking when deserializing the kratos server response. I speculate that this will panic on all struct
s containing models::UiContainer
as there seems to be a mismatch in the models. In particular, UiNodeAttributes
contains the enum variant UiNodeInputAttributes
which is missing the node_type
field. However, the struct UiNodeInputAttributes
, which is defined but never referenced, does contain this field.
pub enum UiNodeAttributes {
...
UiNodeInputAttributes {
/// Sets the input's disabled field to true or false.
#[serde(rename = "disabled")]
disabled: bool,
#[serde(rename = "label", skip_serializing_if = "Option::is_none")]
label: Option<Box<crate::models::UiText>>,
/// The input's element name.
#[serde(rename = "name")]
name: String,
/// OnClick may contain javascript which should be executed on click. This is primarily used for WebAuthn.
#[serde(rename = "onclick", skip_serializing_if = "Option::is_none")]
onclick: Option<String>,
/// The input's pattern.
#[serde(rename = "pattern", skip_serializing_if = "Option::is_none")]
pattern: Option<String>,
/// Mark this input field as required.
#[serde(rename = "required", skip_serializing_if = "Option::is_none")]
required: Option<bool>,
#[serde(rename = "type")]
_type: String,
/// The input's value.
#[serde(rename = "value", skip_serializing_if = "Option::is_none")]
value: Option<serde_json::Value>,
},
...
}
pub struct UiNodeInputAttributes {
/// Sets the input's disabled field to true or false.
#[serde(rename = "disabled")]
pub disabled: bool,
#[serde(rename = "label", skip_serializing_if = "Option::is_none")]
pub label: Option<Box<crate::models::UiText>>,
/// The input's element name.
#[serde(rename = "name")]
pub name: String,
/// 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\".
#[serde(rename = "node_type")]
pub node_type: String,
/// OnClick may contain javascript which should be executed on click. This is primarily used for WebAuthn.
#[serde(rename = "onclick", skip_serializing_if = "Option::is_none")]
pub onclick: Option<String>,
/// The input's pattern.
#[serde(rename = "pattern", skip_serializing_if = "Option::is_none")]
pub pattern: Option<String>,
/// Mark this input field as required.
#[serde(rename = "required", skip_serializing_if = "Option::is_none")]
pub required: Option<bool>,
#[serde(rename = "type")]
pub _type: String,
/// The input's value.
#[serde(rename = "value", skip_serializing_if = "Option::is_none")]
pub value: Option<serde_json::Value>,
}
Reproducing the bug
Cargo.toml
[package]
name = "kratos-sdk-test"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
ory-kratos-client = { version = "0.10.1" }
tokio = { version = "1", features = ["full"] }
src/main.rs
use ory_kratos_client::apis;
#[tokio::main]
async fn main() {
let mut config = apis::configuration::Configuration::new();
config.base_path = String::from("http://127.0.0.1:4433/");
apis::v0alpha2_api::initialize_self_service_registration_flow_without_browser(&config).await.unwrap();
}
cargo run
Relevant log output
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Serde(Error("missing field `nodetype`", line: 1
, column: 497))', src/main.rs:6:98
Relevant configuration
No response
Version
0.10.1
On which operating system are you observing this issue?
Linux
In which environment are you deploying?
Binary
Additional Context
No response
Sorry. I now realize that this should have been put in a different repository.
Revisiting this issue, I see that the bug was quite trivial. If we change #[serde(tag = "nodetype")]
to #[serde(tag = "node_type")]
in ui_node_attributes.rs
, the bug goes away. Coincidentally, OpenAPITools/openapi-generator#14746, which was merged last week, seems to fix this.