aws / aws/chalice

Query params MultiDict.getlist raises KeyError on missing key

Open
#1,634 2 comments 0 reactions 0 assignees View on GitHub
investigating
Dominant language
Python
Stars
11.1k
Forks
1k
Avg merge
1d 22h
Merged PRs (30d)
2

Description

```python
@app.route('/')
def index():
query_params = app.current_request.query_params
stuff = query_params.getlist("stuff") # KeyError if query param not passed in request
```

I believe that it makes sense that a behavior similar to using `get` (fall back to a value) is expected when using `getlist`.

Contributor guide

Open the contributing guide

Research direction

Start by locating the MultiDict implementation and comparing getlist with get, then inspect existing tests for missing query parameters. Clarify the expected fallback value for a missing key, implement the agreed behavior, and add or update a regression test showing that getlist no longer raises KeyError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.