jorgebastida / jorgebastida/gordon
Cannot use double quotes in apigateway responses pattern
- Dominant language
- Python
- Stars
- 2k
- Forks
- 132
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I'm trying to create an apigateway using Gordon, and I want to use double quotes (`"`) in the regex pattern used to decide what response code to return. Unfortunately, Gordon either over-escapes or under-escapes the pattern before it gives it to AWS, causing the stack creation to fail.
Here's the part of the created template that looks wrong to me:
```
"IntegrationResponses": [
{
"SelectionPattern": "",
"StatusCode": "201"
},
{
"SelectionPattern": ".*\"status\":400.*",
"StatusCode": "400"
},
{
"SelectionPattern": "*.\\\"errorMessage\\\".*",
"StatusCode": "500"
}
],
```
You can see the [full template](https://gist.github.com/jakul/88532fca517f3899b97dc956d661a7b7) if you want to, and the relevant [settings.yml](https://github.com/jakul/gordon-regex-error/blob/master/demo/firstapp/settings.yml). I've also created a repo which replicates the problem at https://github.com/jakul/gordon-regex-error.
The [Amazon docs](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-regexes.html) suggest that the correct format for regexes should be:
```
"SelectionPattern": ".*\\"status\\":400.*",
"SelectionPattern": "*.\\"errorMessage\\".*",
```
Can you take a look @jorgebastida ?
Cheers,
Craig
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with demo/firstapp/settings.yml and the generated CloudFormation template from the linked reproducer repository. Compare the escaping of SelectionPattern values containing quotes with the AWS regex documentation, then verify that the resulting stack accepts both response patterns without a creation failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python
- Domain
- api, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100