Skip to content

Chained previous_response_id on CreateResponseArgs not correctly (imo) handling None values #407

@alexkunde

Description

@alexkunde

Hi,

let's say i want to create a new request where my_prev_response_id is an Option, so i don't need to handle input myself.

let request = CreateResponseArgs::default().previous_response_id(my_prev_response_id).build()?;

From what i see in the documentation .previous_response_id() would normally handle Options, but seems to implement a bound requiring it to be a String.

#[serde(skip_serializing_if = "Option::is_none")]
    pub previous_response_id: Option<String>,
.previous_response_id(my_prev_response_id)
    |                  -------------------- ^^^^^^^^^^^^^^^^^^^^ the trait `From<std::option::Option<std::string::String>>` is not implemented for `std::string::String`
    |                  |
    |                  required by a bound introduced by this call

If implement logic to turn a None into an empty string, the API fails since the value must be filled with a valid id if provided.

2025-07-24T11:54:15.027613Z ERROR ai_server::handlers: Failed to get AI response: 
  Error creating response: 
  ApiError(ApiError { 
    message: "Invalid 'previous_response_id': ''. Expected an ID that contains letters, numbers, underscores, or dashes, but this value contained additional characters.", 
    type: Some("invalid_request_error"), 
    param: Some("previous_response_id"), 
    code: Some("invalid_value") })

Can you remove the bound so we can let serde handle the value and correctly remove it if its none?

Thank you for your consideration!

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