rubyonjets/jets

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

Closed this issue · 1 comments

egold commented

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 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. :)

Thanks for the kind report. Took the easier approach for the sake of time. Details in #650