Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ehancement: CLI - Better error message for invalid --app string #3893

Open
1 of 4 tasks
henryruhs opened this issue Dec 7, 2024 · 2 comments
Open
1 of 4 tasks

Ehancement: CLI - Better error message for invalid --app string #3893

henryruhs opened this issue Dec 7, 2024 · 2 comments
Labels
Enhancement This is a new feature or request

Comments

@henryruhs
Copy link

henryruhs commented Dec 7, 2024

Description

A condition is missing for the case that app_path does not contain a colon.

Using Litestar app from env: 'invalid'
Traceback (most recent call last):
  File "/home/henry/miniconda3/envs/facefusion/bin/litestar", line 8, in <module>
    sys.exit(run_cli())
  File "/home/henry/miniconda3/envs/facefusion/lib/python3.10/site-packages/litestar/__main__.py", line 6, in run_cli
    litestar_group()
  File "/home/henry/miniconda3/envs/facefusion/lib/python3.10/site-packages/rich_click/rich_command.py", line 367, in __call__
    return super().__call__(*args, **kwargs)
  File "/home/henry/miniconda3/envs/facefusion/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/henry/miniconda3/envs/facefusion/lib/python3.10/site-packages/rich_click/rich_command.py", line 151, in main
    with self.make_context(prog_name, args, **extra) as ctx:
  File "/home/henry/miniconda3/envs/facefusion/lib/python3.10/site-packages/litestar/cli/_utils.py", line 224, in make_context
    self._prepare(ctx)
  File "/home/henry/miniconda3/envs/facefusion/lib/python3.10/site-packages/litestar/cli/_utils.py", line 206, in _prepare
    env = ctx.obj = LitestarEnv.from_env(ctx.params.get("app_path"), ctx.params.get("app_dir"))
  File "/home/henry/miniconda3/envs/facefusion/lib/python3.10/site-packages/litestar/cli/_utils.py", line 112, in from_env
    loaded_app = _load_app_from_path(app_path)
  File "/home/henry/miniconda3/envs/facefusion/lib/python3.10/site-packages/litestar/cli/_utils.py", line 276, in _load_app_from_path
    module_path, app_name = app_path.split(":")
ValueError: not enough values to unpack (expected 2, got 1)

Either add a condition to _load_app_from_path or introduce a safe_split utility/helper.

URL to code causing the issue

No response

MCVE

litestar --app invalid


### Steps to reproduce

_No response_

### Screenshots

```bash
"![SCREENSHOT_DESCRIPTION](SCREENSHOT_LINK.png)"

Logs

No response

Litestar Version

2.13.0final0

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Note

While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.

Check out all issues funded or available for funding on our Polar.sh dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.
Fund with Polar
@henryruhs henryruhs added the Bug 🐛 This is something that is not working as expected label Dec 7, 2024
@provinzkraut
Copy link
Member

This isn't really a bug. You're passing in an invalid value and are presented with a ValueError, which I think is appropriate. I'm assuming you're looking for a better error message here?

@provinzkraut provinzkraut changed the title Bug: Argument --app causes ValueError Ehancement: CLI - Better error message for invalid --app string Dec 7, 2024
@provinzkraut provinzkraut added Enhancement This is a new feature or request and removed Bug 🐛 This is something that is not working as expected labels Dec 7, 2024
@henryruhs
Copy link
Author

Yeah, something like "Invalid argument passed" instead of an exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement This is a new feature or request
Projects
None yet
Development

No branches or pull requests

2 participants