Skip to content

Prevent PydanticUserError in ApiClient.send for void endpoints (#90) - #94

Merged
oxesoft merged 2 commits into
v2.16-cli-developfrom
fix/90_typeadapter_none
Jun 2, 2026
Merged

Prevent PydanticUserError in ApiClient.send for void endpoints (#90)#94
oxesoft merged 2 commits into
v2.16-cli-developfrom
fix/90_typeadapter_none

Conversation

@oxesoft

@oxesoft oxesoft commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • In the generated ApiClient.send, return None immediately when type_ is None instead of calling TypeAdapter(type_), which raises PydanticUserError
  • Aligns the runtime behaviour with the type_: None -> None overloads, fixing 204 No Content (and other void-response) endpoints

Closes #90

Test plan

  • python3 -m py_compile scripts/datamodel_generate_client.py
  • Regenerate the client and exercise an endpoint with no response body — should return None without raising

🤖 Generated with Claude Code

Short-circuit and return None before constructing TypeAdapter when
type_ is None (e.g. 204 No Content endpoints). TypeAdapter(None) raises
PydanticUserError, and returning None matches the existing overloads.

Closes #90

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the client generation script to handle cases where the expected response type is None by returning None early, and simplifies the JSON parsing logic. The reviewer pointed out that void endpoints returning 204 No Content are not currently supported and will raise an UnexpectedResponse exception, suggesting that 204 should be included in the allowed status codes and handled appropriately.

Comment thread scripts/datamodel_generate_client.py Outdated
Add 204 to the success status codes and short-circuit to None for it
so void endpoints stop raising UnexpectedResponse.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@oxesoft
oxesoft requested a review from rquidute June 2, 2026 19:40
@oxesoft
oxesoft merged commit 4c937d7 into v2.16-cli-develop Jun 2, 2026
1 of 2 checks passed
@oxesoft
oxesoft deleted the fix/90_typeadapter_none branch June 2, 2026 19:44
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

Successfully merging this pull request may close these issues.

2 participants