Skip to content

fix: use JSON.pretty_generate (pretty_unparse removed in json 3.0) - #72

Open
aim2bpg wants to merge 1 commit into
aws:mainfrom
aim2bpg:fix/json-3-pretty-unparse-removed
Open

aim2bpg wants to merge 1 commit into
aws:mainfrom
aim2bpg:fix/json-3-pretty-unparse-removed

Conversation

@aim2bpg

@aim2bpg aim2bpg commented Oct 10, 2026

Copy link
Copy Markdown

JSON.pretty_unparse was removed in json 3.0.0.rc1 (ruby/json CHANGES.md). Under json >= 3.0, any unhandled exception reaching LambdaLogger.log_error crashes with NoMethodError instead of reporting the original error.

pretty_generate is the documented replacement, present since json 0.4.2 (2006), so this works under json 2.x and 3.x alike.

Repro:

require 'json'
JSON.pretty_unparse({ a: 1 }) # NoMethodError under json 3.0

@aim2bpg

aim2bpg commented Nov 22, 2026

Copy link
Copy Markdown
Author

Hi team, just a friendly ping on this PR when you have a moment.

This is a one-line fix: JSON.pretty_unparse was removed in json 3.0, so when LambdaLogger.log_error receives an unhandled exception it raises a NoMethodError instead of reporting the original error, which makes the real failure hard to diagnose. JSON.pretty_generate is available in both json 2.x and 3.x, so behavior is unchanged for existing users.

It would be great if someone could take a look (and approve the workflow run if CI is waiting on it). Happy to adjust anything if needed. Thanks for your time!

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

Successfully merging this pull request may close these issues.

1 participant