Comments (4)
I think this has been resolved in the development branch. @zoopp are you able to give that branch a try to confirm if the problem remains?
from litestar.
@cofin I gave it a try now but the issue is still reproducible with the MCVE above:
!!! I'm using the standard logging version output as it formats the exception in a readable manner
!!! but the outcome is essentially the same regardless if using structlog or standard logging.
(litestar)
┌─┤10:11:07│mihai@mobilews:~/bug
└──────────╼ litestar --app bug:app run --reload
Using Litestar app from env: 'bug:app'
Starting server process ───────────────────────────────────────────────────────────────────────────────────────────────────────
┌──────────────────────────────┬──────────────────────┐
│ Litestar version │ 2.6.0 │
│ Debug mode │ Disabled │
│ Python Debugger on exception │ Disabled │
│ CORS │ Disabled │
│ CSRF │ Disabled │
│ OpenAPI │ Enabled path=/schema │
│ Compression │ Disabled │
│ Middlewares │ LoggingMiddleware │
└──────────────────────────────┴──────────────────────┘
INFO: Will watch for changes in these directories: ['/home/mihai/bug']
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [150319] using WatchFiles
INFO: Started server process [150321]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: 127.0.0.1:58246 - "POST / HTTP/1.1" 500 Internal Server Error
ERROR - 2024-02-05 10:11:12,310 - litestar - config - exception raised on http connection to route /
Traceback (most recent call last):
File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/serialization/msgspec_hooks.py", line 186, in decode_json
return _msgspec_json_decoder.decode(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
msgspec.DecodeError: JSON is malformed: trailing comma in object (byte 10)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/middleware/exceptions/middleware.py", line 192, in __call__
await self.app(scope, receive, send)
File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/middleware/base.py", line 129, in wrapped_call
await original__call__(self, scope, receive, send) # pyright: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/middleware/logging.py", line 112, in __call__
await self.log_request(scope=scope, receive=receive)
File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/middleware/logging.py", line 126, in log_request
extracted_data = await self.extract_request_data(request=scope["app"].request_class(scope, receive))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/middleware/logging.py", line 179, in extract_request_data
value = await value
^^^^^^^^^^^
File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/data_extractors.py", line 277, in extract_body
return await request.json()
^^^^^^^^^^^^^^^^^^^^
File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/connection/request.py", line 134, in json
self._json = self._connection_state.json = decode_json(
^^^^^^^^^^^^
File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/serialization/msgspec_hooks.py", line 191, in decode_json
raise SerializationException(str(msgspec_error)) from msgspec_error
litestar.exceptions.base_exceptions.SerializationException: JSON is malformed: trailing comma in object (byte 10)
Traceback (most recent call last):
File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/serialization/msgspec_hooks.py", line 186, in decode_json
return _msgspec_json_decoder.decode(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
msgspec.DecodeError: JSON is malformed: trailing comma in object (byte 10)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/middleware/exceptions/middleware.py", line 192, in __call__
await self.app(scope, receive, send)
File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/middleware/base.py", line 129, in wrapped_call
await original__call__(self, scope, receive, send) # pyright: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/middleware/logging.py", line 112, in __call__
await self.log_request(scope=scope, receive=receive)
File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/middleware/logging.py", line 126, in log_request
extracted_data = await self.extract_request_data(request=scope["app"].request_class(scope, receive))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/middleware/logging.py", line 179, in extract_request_data
value = await value
^^^^^^^^^^^
File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/data_extractors.py", line 277, in extract_body
return await request.json()
^^^^^^^^^^^^^^^^^^^^
File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/connection/request.py", line 134, in json
self._json = self._connection_state.json = decode_json(
^^^^^^^^^^^^
File "/home/mihai/.virtualenvs/litestar/lib/python3.11/site-packages/litestar/serialization/msgspec_hooks.py", line 191, in decode_json
raise SerializationException(str(msgspec_error)) from msgspec_error
litestar.exceptions.base_exceptions.SerializationException: JSON is malformed: trailing comma in object (byte 10)
from litestar.
This issue has been closed in #3109. The change will be included in the upcoming patch release.
from litestar.
A fix for this issue has been released in v2.6.1
from litestar.
Related Issues (20)
- Docs: Add common recipes/FAQ section HOT 1
- Bug: Litestar instance or factory not found HOT 1
- Enhancement: allow finer tuning `LoggingConfig` for exception logging HOT 1
- Bug: SQLAlchemy models with default=func.now() error with Unexpected default type HOT 5
- Bug: [OpenAPI] Upload file is not possible when defined as Optional HOT 2
- Bug: Using plugin results in DTO given to dto parameter not being used for return HOT 2
- CI: Fix devcontainer config HOT 1
- DTO backend does not transferring mappings with nested models HOT 10
- Bug: SerializationException when running modeling-and-features demo from docs HOT 3
- Bug: Can't convert sqlalchemy model to pydantic model which is inherited from BaseModel HOT 1
- Enhancement: Add Pydantic's error dictionary to ValidationException's extra dict
- Enhancement: make `SessionMiddleware` return custom types HOT 3
- Bug: OpenAPI docs fail to generate with certain validators and pydantic v1 HOT 4
- Bug: Multi-body response incompatible with LoggingMiddleware HOT 3
- Bug: test failures
- Bug: `return_dto` is silently ignored if return data type does not match DTO definition HOT 1
- Bug: Test error
- Enhancement: add `default_json_serializer` to `__all__` in `litestar.logging.config`
- Docs: Migrating to Litestar from Django HOT 1
- Decoupled, transactional communication of domain events and commands
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from litestar.