Auto-Instrumentation creates syntax error
natematykiewicz opened this issue · comments
The auto-instrumentation patches do not work with Ruby 3 hashes that do not have a value.
This is perfectly valid Ruby 3.2.2 code in a Rails controller:
def base_cache_key
{
path: request.env['PATH_INFO'],
timestamp: (Time.now.to_i / 300),
publishing_status:,
}
end
Which causes this syntax error when deployed to production:
Nov 3 03:00:19 PM bundler: failed to load command: puma (/app/vendor/bundle/ruby/3.2.0/bin/puma)
Nov 3 03:00:19 PM /app/vendor/bundle/ruby/3.2.0/gems/scout_apm-5.3.5/lib/scout_apm/auto_instrument/instruction_sequence.rb:11:in `compile': /app/app/controllers/api/v4/experiences_controller.rb:86: syntax error, unexpected ':', expecting => (SyntaxError)
Nov 3 03:00:19 PM ...che_key'"]){publishing_status}:,
Nov 3 03:00:19 PM ... ^
Nov 3 03:00:19 PM
Nov 3 03:00:19 PM from /app/vendor/bundle/ruby/3.2.0/gems/scout_apm-5.3.5/lib/scout_apm/auto_instrument/instruction_sequence.rb:11:in `load_iseq'
The workaround is to add a value to the Hash, even though it's not necessary anymore.
def base_cache_key
{
path: request.env['PATH_INFO'],
timestamp: (Time.now.to_i / 300),
publishing_status: publishing_status,
}
end
Which version of parser
are you using?
@jrothrock 3.2.2.4 (the latest)
This seems to be happening when the hash value is a method call.
That would align with my error as well. publishing_status
is a method.