aws / aws/aws-sam-cli

sam local start-api is able to serve invalid routes

Open
#2,706 3 comments 0 reactions 0 assignees View on GitHub
area/local/start-api type/bug
Dominant language
Python
Stars
6.7k
Forks
1.2k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

### Description:

The following template, with the `/e{id}` route:
```
GetFunction:
Type: AWS::Serverless::Function
Properties:
Handler: handlers/get.handler
Description: some handler
Events:
Api:
Type: Api
Properties:
Path: /e{id}
Method: GET
```

works, but I think it shouldn't (also according [to the documentation](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-routes.html#http-api-develop-routes.evaluation))

### Steps to reproduce:
- Define a Lambda and attach it to that route
- run `sam local start-api --warm-containers EAGER --skip-pull-image`
- open a browser and point to http://localhost:300/esomething
- the lambda will receive "something" as the "id" parameter

### Observed result:
Screenshot 2021-03-11 at 18 23 08

### Expected result:
I think CDK rejects that format and so API Gateway and so should SAM cli.

```
Parts are validated against this regular expression: ^(\{[\w.-]+\+?\}|[a-zA-Z0-9._-]+)$ (Service: AmazonApiGatewayV2);
```

### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

1. OS: macOS
2. `sam --version`: `SAM CLI, version 1.20.0`
3. AWS region: eu-central-1

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.