Skip to content

Bug: query params doesn't work? #2815

@thompson0012

Description

@thompson0012

Description

i am trying the litestar library for the api development. i found there are some stranges

doc: https://docs.litestar.dev/latest/usage/routing/parameters.html#query-parameters

from litestar import Litestar, get


@get("/", sync_to_thread=False)
def index(param: str) -> dict[str, str]:
    return {"param": param}


app = Litestar(route_handlers=[index])
> curl http://127.0.0.1:8000/?param=foo
{"param":"foo"}
> curl http://127.0.0.1:8000/?param=bar
{"param":"bar"}

but the terminal show me when i follow the instruction

zsh: no matches found: http://localhost:8000?param=uiyhkjh

when i remove the query param, it showed

{"status_code":400,"detail":"Missing required query parameter 'param' for url http://localhost:8000/"}%      

i have no idea on the issue, i just simply follow the guidelines, without any modification

URL to code causing the issue

No response

MCVE

# Your MCVE code here

Steps to reproduce

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

Screenshots

"![SCREENSHOT_DESCRIPTION](SCREENSHOT_LINK.png)"

Logs

No response

Litestar Version

Version(major=2, minor=4, patch=1, release_level='final', serial=0)

Platform

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionThis is a question and further information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions