Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Variables Path Issue Error Message #143

Closed
3 tasks done
tongueroo opened this issue Jan 14, 2019 · 1 comment
Closed
3 tasks done

Multiple Variables Path Issue Error Message #143

tongueroo opened this issue Jan 14, 2019 · 1 comment
Labels

Comments

@tongueroo
Copy link
Collaborator

tongueroo commented Jan 14, 2019

Checklist

  • Upgrade Jets: Are you using the latest version of Jets? This allows Jets to fix issues fast. There's a jets upgrade command that makes this a simple task. There's also an Upgrading Guide: http://rubyonjets.com/docs/upgrading/
  • Reproducibility: Are you reporting a bug others will be able to reproduce and not asking a question. If you're unsure or want to ask a question, do so on https://community.rubyonjets.com
  • Code sample: Have you put together a code sample to reproduce the issue and make it available? Code samples help speed up fixes dramatically. If it's an easily reproducible issue, then code samples are not needed. If you're unsure, please include a code sample.

My Environment

Software Version
Operating System Amazon Linux
Jets 1.5.3
Ruby 2.5.3

Expected Behaviour

Deploying Jets application with routes that have different path variables under the same parent route should work.

Current Behavior

Deploying with a config/routes.rb that has:

get 'posts/:id', to: 'posts#show'
post 'post/:post_id/reveal', to: 'posts#show'

Produces this error:

A sibling ({post_id}) of this resource already has a variable path part -- only one is allowed

CloudFormation error screenshot:

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
# add back in the route that cause the issue
jets deploy 

Note it is helpful to comment out route that causes the issue and deploy successfully first and then deploy again.

Here's also manual reproduction using the API Gateway Console:

multiple-variables-path-part-issue

Code Sample

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

Solution Suggestion

  1. Add docs noting this API Gateway constraint and how to currently avoid it. That's a big win and will help save folks time right now.
  2. Upon route building, check for “multiple variable part path definitions” that collide and error with an informative message to the user. So the user finds out about this early as we can help with the process, locally. Even before they try to deploy. When they deploy check the same logic and also provide same information message in case they deploy without checking locally. Something like

API Gateway only allows one unique variable path. [screenshot link]. You must use the same variable name within the same parent route path. Example: /posts/:id and /posts/:post_id/reveal should both be /posts/:id and /posts/:id/reveal.

Something like that, the message can be improved and can tell the users how to fix it.

References

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

@tongueroo tongueroo added the bug label Jan 14, 2019
tongueroo added a commit that referenced this issue Jan 17, 2019
* Multiple Variables Path Issue Error Message #143
* Add api gateway considerations docs
tongueroo added a commit that referenced this issue Jan 17, 2019
* Multiple Variables Path Issue Error Message #143
* Add api gateway considerations docs
tongueroo added a commit that referenced this issue Jan 17, 2019
* Multiple Variables Path Issue Error Message #143
* Add api gateway considerations docs
@tongueroo
Copy link
Collaborator Author

Done in PR #154

Released in v1.5.9 CHANGELOG

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant