rubyonjets/jets

APIGW Sibling Variable Limit: Report Compatibility Issues During Local Development

Closed this issue · 1 comments

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 cloud9
Jets 3.0.16
Ruby 2.7.2

Expected Behaviour

Let us know in local development that a route will not work before getting to the jets deploy and finding out about the error on APIGW.

Current Behavior

We get to jets deploy and CloudFormation errors with APIGW error about:

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

This is cryptic for most users who are not using APIGW every day. To help explain the error, this sample wont work.

config/routes.rb

Jets.application.routes.draw do
  resources :posts
  # :foo and *catchcall conflicts. Will get this error:
  #
  #     A sibling ({catchall+}) of this resource already has a variable path part -- only one is allowed
  #
  get ':foo/posts', to: 'posts#index'
  any "*catchall", to: "jets/public#show"
end

You see, :foo conflicts with *catchall since APIWG sadly does not support siblings with different variables. This is explained in more detail at these docs: https://rubyonjets.com/docs/considerations/api-gateway/

Step-by-step reproduction instructions

Deploy this code: https://github.com/tongueroo/jets-bug-apigw-sibling-variable

Then go into config/routes.rb and uncomment out the line:

get ':foo/posts', to: 'posts#index' - uncomment out this route to reproduce

Deploy again:

jets deploy

Code Sample

https://github.com/tongueroo/jets-bug-apigw-sibling-variable

Solution Suggestion

Possible solution:

Middleware that only runs development mode locally that checks the routes for invalid APIGW routes. It can throw an exception and link to https://rubyonjets.com/docs/considerations/api-gateway/ to explain and more gently guide the user.

This is fixed in Jets 5