aws / aws/chalice

[TEST/LOCAL] Authorizer behave differently once deployed than in test client / chalice local

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

Description

### Description

API Gateway forbids non number / string in the authorizer result (eg: list) and returns a 500 error specifying an incorrect Authorizer setup.

Chalice local and Chalice test client allows it and transmit it correctly as an authorizer context to the routes using the authorizer.

To reproduce (not fully tested - cleaned version of the bug detected)

```
@app.authorizer()
def authorizer(auth_request):
return AuthResponse(routes=["*"], principal_id="x", context={"DATA": ["test","test2"]})

@app.route("/test", methods=["GET"], authorizer=authorizer)
def test():
return {"test": "test"}
```

### Expected behaviour

This example should fail in chalice local and in chalice.test.client in order to be consistent with AWS target behaviour.

### Reference

https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-output.html

```
The returned values are all stringified. Notice that you cannot set a JSON object or array as a valid value of any key in the context map.
```

Contributor guide

Open the contributing guide

Research direction

Start with the authorizer handling used by Chalice local and chalice.test.client, focusing on how AuthResponse context values are passed to routes. Add coverage using the reported list-valued context example, and verify both clients reject it consistently with the AWS API Gateway behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
api, authorization, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.