Fix Ruby 3.2+ compatibility in aws-sdk-neptunedata detailed_message overrides#3381
Open
ricardogpsf wants to merge 2 commits into
Open
Conversation
In Ruby 3.2, Exception#full_message was updated to internally call detailed_message(highlight:) with a keyword argument. All 34 error classes in aws-sdk-neptunedata override detailed_message to expose the API-level field, but none of them accepted the highlight: keyword, causing ArgumentError when Ruby or any tooling (e.g. OpenTelemetry SDK's span.record_exception) calls full_message on these exceptions. The fix adds `highlight: true, **` to each override, making them compatible with Ruby 3.2+ while remaining fully backward compatible with earlier Ruby versions where full_message does not call detailed_message with keyword arguments. Fixes: ArgumentError: wrong number of arguments (given 1, expected 0)
Ruby 3.2 updated Exception#full_message to call detailed_message(highlight:) with a keyword argument. The errors_module.mustache template generates detailed_message overrides for error members, but the generated signature did not accept the highlight: keyword, causing ArgumentError. Update error_list.rb to expose a detailed_message flag on members named detailed_message, and update the template to generate: def detailed_message(highlight: true, **) for those members, maintaining backward compatibility with Ruby < 3.2. The generated aws-sdk-neptunedata/errors.rb was already updated in the previous commit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In Ruby 3.2,
Exception#full_messagewas updated to internally calldetailed_message(highlight:)passing a keyword argument (source). All 34 error classes inaws-sdk-neptunedataoverridedetailed_messageto expose the API-leveldetailed_messagefield, but none accepted thehighlight:keyword — causing anArgumentErrorwhenever Ruby or tooling callsfull_messageon these exceptions.A common trigger is OpenTelemetry SDK's
span.record_exception(e), which callse.full_message(highlight: false, order: :top)to capture the stacktrace. This silently breaks tracing and any instrumentation that records Neptune exceptions on spans.Change
Added
highlight: true, **to all 34detailed_messageoverrides inerrors.rband updated the corresponding.rbstype signatures.Backward Compatibility
Fully backward compatible. Keyword arguments with defaults are valid Ruby syntax since 2.0. In Ruby < 3.2,
full_messagenever callsdetailed_messagewith keyword arguments, so the added parameter is never passed — no behavior change.Note on Code Generation
errors.rbandsig/errors.rbsare generated files. The corresponding generator template will also need to be updated to preserve this fix on future regeneration.