Bug: TypeError: Using a non-empty mutable collection as a default value is unsafe on Python 3.14
Describe the bug
apiup starts and prints the banner but crashes when Litestar registers the route handlers.
Steps to reproduce
Error
TypeError: Using a non-empty mutable collection ({'_mock': True, 'status': 200,
'note': 'no example in spec'}) as a default value is unsafe. Instead configure
a `default_factory` for this field.
Root cause
In server.py, route handlers were defined with mutable dict default arguments:
async def _handler(b: Any = _body, s: int = _status) -> Any:
...
Litestar introspects handler signatures at registration time. On Python 3.14 this raises TypeError when a default value is a non-empty mutable collection.
Fix
Replace default-argument pattern with a _make_handler() closure factory at module level. The body and status code are captured in the closure — no default arguments, no mutable defaults. Body is also pre-serialised to bytes so Litestar never inspects the dict.
Environment
- Python 3.14.3
- apiup 0.2.0
- litestar latest
- Fedora Silverblue
Labels
bug
Bug:
TypeError: Using a non-empty mutable collection as a default value is unsafeon Python 3.14Describe the bug
apiupstarts and prints the banner but crashes when Litestar registers the route handlers.Steps to reproduce
Error
Root cause
In
server.py, route handlers were defined with mutabledictdefault arguments:Litestar introspects handler signatures at registration time. On Python 3.14 this raises
TypeErrorwhen a default value is a non-empty mutable collection.Fix
Replace default-argument pattern with a
_make_handler()closure factory at module level. The body and status code are captured in the closure — no default arguments, no mutable defaults. Body is also pre-serialised tobytesso Litestar never inspects the dict.Environment
Labels
bug