!SuQCzDjUGWGtJAiyIZ:matrix.org

Litestar General

1137 Members
Main discussion room for the Starlite API open source library4 Servers

Load older messages


SenderMessageTime
11 Jan 2024
@_discord_870862500671934525:t2bot.iopltoledo I just wanted to grasp whether you were here to stay. It's always a risk to adopt new technologies as building blocks of applications, because you never know if the tech will endure or not. But I'm feeling good about this project and definetely will be following you guys closely from now on. I'll also check out those office hours recordings. Keep up the good work! 03:16:19
@_discord_396519450905673730:t2bot.iocofin Most of the maintainers (including me) are using Litestar at their jobs. I definitely plan to stick around! Feel free to ask any questions you might have. I'm sure others will offer their perspectives as well. 03:21:28
@_discord_314787529100361748:t2bot.ioalc.alc Just to add, there are some professional and some hobby projects (some probably make $ if you are looking at that angle) in <#1064129391413690479> that use litestar 03:22:10
@_discord_489485360645275650:t2bot.ioCoffee I have nothing else to add as this sums it up for me as well 🙂 03:22:18
@_discord_870862500671934525:t2bot.iopltoledo Sounds really cool, i'll check this out 03:23:13
@_discord_314787529100361748:t2bot.ioalc.alc If you ever end up using litestar longterm, you can add yours there (suggestion 🙂 ) 03:24:15
@_discord_314787529100361748:t2bot.ioalc.alc this seems to be partially supported at least with this minimal example that uses dataclass, I have yet to check if this will work on pydantic and msgspec models. I say partial cause even though the reponse seems to work, the openapi schema just shows one of the model and not the union. I will let openapi experts pitch in

from dataclasses import dataclass

from litestar import Litestar, get
from typing_extensions import List, Union

@dataclass
class ModelOne:
    name: str

@dataclass
class ModelTwo:
    names: List[str]

@get()
async def route(model: int) -> Union[ModelOne, ModelTwo]:
    return ModelOne('model one') if model == 1 else ModelTwo(['model', 'two'])

app = Litestar([route])
03:39:00
@_discord_314787529100361748:t2bot.ioalc.alc https://github.com/litestar-org/litestar/issues/2954
can anyone confirm this?
08:34:17
@_discord_872576125384147005:t2bot.ioGitHub Helper
<:issue_open:882464248951877682> [litestar-org/litestar] Bug: Logs and Stack traces are not visible OOTB in Python3.12
Alc-Alc

# Description
Logging (on routes) and also stack trace (when using litestar.testing.create_test_client in debug mode) don't appear to be printed on the terminal when executed in Python 3.12. Running the minimal example in Python 3.8, I can see contents of the "Logs" section in my terminal; both a WARNING and an ERROR log, along with a stack trace. However, neither is visible when run on Python 3.12. There is one workaround (that I am aware of) shared by @cofin in the Discord server but (IMO) these functionalities should simply "just work".

@cofin's example modified to suit the example code (the actual MCVE is under the MCVE section)

This at least makes one of the log ("WARNING" log) show up on 3.12, but no "ERROR" log and stack trace.

import logging
from litestar import get, Request
from litestar.logging.config import LoggingConfig
from litestar.testing import create_test_client


@get()
async def evil_route(request: Request) -> str:
    request.logger.warning("you can't see me")
    1 / 0
    return "so, you will never catch me"


with create_test_client(
    [evil_route],
    logging_config=LoggingConfig(
        root={"level": logging.getLevelName(logging.INFO), "handlers": ["console"]},
        formatters={
            "standard": {
                "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
            }
        },
    ),
) as client:
    response = client.get("")
    assert response.status_code == 500

PS: This may probably be a duplicate issue, so feel free to close as one.

# URL to code causing the issue
No response

# MCVE
from litestar import get, Request
from litestar.testing import create_test_client

@get()
async def evil_route(request: Request) -> str:
    request.logger.warning("you can't see me")
    1 / 0
    return "so, you will never catch me"

with create_test_client([evil_route]) as client:
    response = client.get("")
    assert response.status_code == 500

# Steps to reproduce
1. Save as "some_python_file.py"
2. Run `python some_python_file.py`
4. See error (actually you can't :p that is the error)

# Screenshots
"![SCREENSHOT_DESCRIPTION](SCREENSHOT_LINK.png)"

# Logs
```bash
WARNING - ,-555869153 - root - http - you can't see me
ERROR - ,-555869152 - litestar - middleware - exception raised on http connection to route /

Traceback (most recent call last):
File "litestar/litestar/middleware/exceptions/middleware.py", line 192, in call
await self.app(scope, receive, send)
File "litestar/litestar/routes/http.py", line 82, in handle
response = await self._get_response_for_request(
File "litestar/litestar/routes/http.py", li...

Labels
Bug 🐛

Created

08:34:17
@_discord_314787529100361748:t2bot.ioalc.alc A commenter seems to say it is not reproducible, but it seems so far me (use the code under the "MCVE" section) 08:34:50
@_discord_314787529100361748:t2bot.ioalc.alc thanks euri10 , idk if I am losing my sanity, what OS are you on? idk if that matters 08:41:28
@_discord_406022421636841472:t2bot.ioeuri10 debian 08:41:47
@_discord_406022421636841472:t2bot.ioeuri10 on 3.11 I get a trace 08:42:06
@_discord_314787529100361748:t2bot.ioalc.alc I tried this on 3.8 I do get the entire stuff (logs + trace), on 3.12 I get nothing, on a mac 08:42:27
@_discord_314787529100361748:t2bot.ioalc.alc why tf did I select Linux in the checkbox :/ 08:42:57
@_discord_406022421636841472:t2bot.ioeuri10 unfortunately i dont have a mac to test except a old vm I try as much as possible not to open 🙂 08:48:13
@_discord_314787529100361748:t2bot.ioalc.alc thank you for confirming quickly, now I know at least part of the issue is true 08:50:15
@_discord_633628220461154325:t2bot.ioFergus Hi alc.alc, thanks for getting back so quickly. If it helps I was using Ubuntu 09:04:05
@_discord_406022421636841472:t2bot.ioeuri10 upgrading to 3.12 is a pain for me atm 09:59:12
@_discord_314787529100361748:t2bot.ioalc.alc guess we will have to wait until someone with 3.12 on a mac can confirm 10:33:48
@_discord_1018449897969696788:t2bot.iokvdm.dev joined the room.12:43:38
@aedify_swi:matrix.org@aedify_swi:matrix.org left the room.14:24:54
@_discord_396519450905673730:t2bot.iocofin It's the console handler vs queue_listener config 14:43:26
@_discord_396519450905673730:t2bot.iocofin at least, that's what my working theory has been the last few days 14:43:47
@_discord_396519450905673730:t2bot.iocofin There's this woraround for 3.12 in place: https://github.com/cofin/litestar/blob/main/litestar/logging/standard.py#L15 14:44:24
@_discord_882578555937112074:t2bot.ioyoursecret joined the room.17:14:55
12 Jan 2024
@_discord_1195380310653800510:t2bot.iouhvg4aufyncrfwb joined the room.15:18:02
@_discord_344751717122048000:t2bot.iozkull4960 joined the room.15:20:55
@_discord_900453511211384834:t2bot.iopedro.diaz "Provider for key order_by_filter is already defined under the different key order_by_filter. If you wish to override a provider, it must have the same key." how?? 15:26:41
@_discord_314787529100361748:t2bot.ioalc.alc you are most likely passing the same dependency at two different layers 15:30:40

Show newer messages


Back to Room ListRoom Version: 9