rubyonjets / jets

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

Minor issue with method names with exclamation point (!) or other unallowed characters in Lambda function names #520

Closed egold closed 1 year ago

egold commented 3 years ago

Checklist

My Environment

Software Version
Operating System macOS 10.15.7
Jets 2.3.18
Ruby 2.5.5

Expected Behaviour

When deploying a Ruby method/class whose name would violate AWS Lambda naming conventions, the failure message is somewhat esoteric and requires tracking down an error message in CloudFormation. The expectation was to see some sort of error/exception/validation from Jets when trying to deploy.

Current Behavior

Jets deploy fails and have to look in CloudFormation event logs to see what happened.

Step-by-step reproduction instructions

  1. Create a simple controller
  2. Create a method in that controller with a ! character in its name, such as authenticate_request!
  3. Try to run jets deploy
  4. Notice it fails part of the way through and says to check CloudFormation for details

Code Sample

Fails:

class ApiController < ApplicationController
  def authenticate_request!
  end
end

Works:

class ApiController < ApplicationController
  def authenticate_request # no "!" in method name
  end
end

Solution Suggestion

Since Jets is already traversing the class/method hierarchy in order to derive names for Lambda functions, it would be cool if it provided a quick validation that the method names only contain allowed characters.

Or even cooler if it automatically turned things like ! into Bang or something valid so that people can follow Ruby naming conventions while their generated Lambda functions follow AWS requirements. :)

tongueroo commented 1 year ago

Thanks for the kind report. Took the easier approach for the sake of time. Details in https://github.com/boltops-tools/jets/pull/650