Conversation
fix(client): mark some request bodies as optional
| if origin == dict and is_mapping(data): | ||
| items_type = get_args(stripped_type)[1] | ||
| return {key: _transform_recursive(value, annotation=items_type) for key, value in data.items()} |
There was a problem hiding this comment.
Sync call inside async function
In _async_transform_recursive, this dict origin branch calls the sync _transform_recursive instead of await _async_transform_recursive. Every other recursive branch in this async function correctly uses the async variant (e.g., line 375 for lists, line 383 for unions). This means dict values with nested typed dicts or other complex types will be transformed synchronously, which is inconsistent and could produce incorrect results if any downstream transform relies on async behavior.
Compare with the sync version at line 184, which correctly calls _transform_recursive.
| if origin == dict and is_mapping(data): | |
| items_type = get_args(stripped_type)[1] | |
| return {key: _transform_recursive(value, annotation=items_type) for key, value in data.items()} | |
| return {key: await _async_transform_recursive(value, annotation=items_type) for key, value in data.items()} |
Note: Since await cannot be used directly in a dict comprehension, this would need to be rewritten as a loop:
result = {}
for key, value in data.items():
result[key] = await _async_transform_recursive(value, annotation=items_type)
return resultPrompt To Fix With AI
This is a comment left during a code review.
Path: src/brainbase/_utils/_transform.py
Line: 348-350
Comment:
**Sync call inside async function**
In `_async_transform_recursive`, this `dict` origin branch calls the **sync** `_transform_recursive` instead of `await _async_transform_recursive`. Every other recursive branch in this async function correctly uses the async variant (e.g., line 375 for lists, line 383 for unions). This means dict values with nested typed dicts or other complex types will be transformed synchronously, which is inconsistent and could produce incorrect results if any downstream transform relies on async behavior.
Compare with the sync version at line 184, which correctly calls `_transform_recursive`.
```suggestion
return {key: await _async_transform_recursive(value, annotation=items_type) for key, value in data.items()}
```
Note: Since `await` cannot be used directly in a dict comprehension, this would need to be rewritten as a loop:
```python
result = {}
for key, value in data.items():
result[key] = await _async_transform_recursive(value, annotation=items_type)
return result
```
How can I resolve this? If you propose a fix, please make it concise.|
🧪 Testing To try out this version of the SDK: Expires at: Thu, 16 Apr 2026 12:10:05 GMT |
deae823 to
5b3021d
Compare
5b3021d to
20655dd
Compare
Automated Release PR
4.1.0 (2026-03-17)
Full Changelog: v4.0.0...v4.1.0
Features
NotGivenfor body (#67) (3ad7f25)X-Stainless-Read-Timeoutheader (#63) (a594c75)Bug Fixes
model_dumpandmodel_dump_jsonfor Pydantic v1 (898ca7b)by_aliasunless set (887a8ec)Chores
httpx-aiohttpversion to 0.1.9 (7aeb4c8)actions/github-script(bdad5ed)api.mdfiles (034e708)--fixargument to lint script (0b1e68e)test_proxy_environment_variablesmore resilient (f79d30c)test_proxy_environment_variablesmore resilient to env (08e33e4)pyproject.tomlfile (f87b268)actions/checkoutversion (54d6bd9)get_platformtest (ef07d85)Documentation
This pull request is managed by Stainless's GitHub App.
The semver version number is based on included commit messages. Alternatively, you can manually set the version number in the title of this pull request.
For a better experience, it is recommended to use either rebase-merge or squash-merge when merging this pull request.
🔗 Stainless website
📚 Read the docs
🙋 Reach out for help or questions