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

This changes the behavior of Kernel#puts in a subtle, problematic way #24

Closed
myronmarston opened this issue Sep 26, 2022 · 1 comment
Closed

Comments

@myronmarston
Copy link

Kernel#puts is documented as returning nil, and that is how it normally behaves:

$ irb
2.7.5 :001 > puts "abc"
abc
 => nil

However, in this project you monkey patch Kernel#puts. A (presumably unintended) side effect of that monkey patch is that it changes the return value to an Integer (since that's what AwsLambdaRuntimeInterfaceClient::TelemetryLoggingHelper.telemetry_log_sink.write(msg) returns, and that's the last line of your puts redefinition).

To make your monkey patch safer, it should still return nil from puts (e.g. by adding a last line to the method of nil).

Concretely, this led to an exception I got from code that assumed that puts does indeed return nil but when run in a lambda that wasn't true.

@mullermp
Copy link
Contributor

This is handled now in the latest release:

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

No branches or pull requests

2 participants