rubyonjets / jets

Ruby on Jets
http://rubyonjets.com
MIT License
2.6k stars 181 forks source link

Improve Route Change Detection: Path Variables #144

Closed tongueroo closed 5 years ago

tongueroo commented 5 years ago

Checklist

My Environment

Software Version
Operating System Amazon Linux
Jets 1.5.3
Ruby 2.5.3

Expected Behaviour

Should be able to change config/routes.rb from:

get  "posts/:id", to: "posts#show"

to

get  "posts/:post_id", to: "posts#show"

And deploy successfully.

Current Behavior

When we deploy the CloudFormation stack rolls back because API Gateway fails to create the new route.

cloudformation-error-multiple-variables-path

Step-by-step reproduction instructions

git clone https://github.com/tongueroo/jets-issue-path-variables demo
cd demo
# comment out the multiple route so we can get a full succcessful deploy first
# https://github.com/tongueroo/jets-issue-path-variables/blob/b7be42eb0ad2bd933461f48ab328330dd4674c9e/config/routes.rb#L5
jets deploy
# change the route to get  "posts/:post_id", to: "posts#show"
jets deploy 

Here's a manual reproduction also:

multiple-variables-path-part-issue

Code Sample

https://github.com/tongueroo/jets-issue-path-variables

Solution Suggestion

The route change detection code should account for this case. Relevant code area: https://github.com/tongueroo/jets/blob/master/lib/jets/resource/api_gateway/rest_api/routes.rb#L10

References

Original discussion: https://community.rubyonjets.com/t/jets-deploy-create-failed-aws-stack-apigateway-embedded/52

tongueroo commented 5 years ago

Released in v1.5.10