Commit 4bd22da
giulio-leone
fix: coerce
`model_dump()` in `_compat.py` declares `by_alias: bool | None = None`
but passes the value directly to Pydantic v2's `model_dump()`, which
expects a `bool`. When `by_alias` is `None` (the default), pydantic-core's
Rust serializer raises `TypeError: argument 'by_alias': 'NoneType' object
cannot be converted to 'PyBool'`.
This only manifests when DEBUG logging is enabled, because the affected
call path is inside `_build_request()`'s `log.isEnabledFor(logging.DEBUG)`
block.
Apply `bool(by_alias)` (matching the existing Pydantic v1 path on line 157)
to coerce `None` → `False` safely.
Fixes #2921
Signed-off-by: Giulio Leone <6887247+giulio-leone@users.noreply.github.com>by_alias to bool in model_dump to prevent TypeError1 parent 15afa21 commit 4bd22da
2 files changed
Lines changed: 10 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | | - | |
| 152 | + | |
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
161 | 169 | | |
162 | 170 | | |
163 | 171 | | |
| |||
0 commit comments