Skip to content

Fix Ruby 3.2+ compatibility in aws-sdk-neptunedata detailed_message overrides#3381

Open
ricardogpsf wants to merge 2 commits into
aws:version-3from
ricardogpsf:fix/neptunedata-detailed-message-ruby-3-2-compat
Open

Fix Ruby 3.2+ compatibility in aws-sdk-neptunedata detailed_message overrides#3381
ricardogpsf wants to merge 2 commits into
aws:version-3from
ricardogpsf:fix/neptunedata-detailed-message-ruby-3-2-compat

Conversation

@ricardogpsf
Copy link
Copy Markdown

Summary

In Ruby 3.2, Exception#full_message was updated to internally call detailed_message(highlight:) passing a keyword argument (source). All 34 error classes in aws-sdk-neptunedata override detailed_message to expose the API-level detailed_message field, but none accepted the highlight: keyword — causing an ArgumentError whenever Ruby or tooling calls full_message on these exceptions.

A common trigger is OpenTelemetry SDK's span.record_exception(e), which calls e.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 34 detailed_message overrides in errors.rb and updated the corresponding .rbs type signatures.

# Before
def detailed_message
  @data[:detailed_message]
end

# After
def detailed_message(highlight: true, **)
  @data[:detailed_message]
end

Backward Compatibility

Fully backward compatible. Keyword arguments with defaults are valid Ruby syntax since 2.0. In Ruby < 3.2, full_message never calls detailed_message with keyword arguments, so the added parameter is never passed — no behavior change.

Note on Code Generation

errors.rb and sig/errors.rbs are generated files. The corresponding generator template will also need to be updated to preserve this fix on future regeneration.

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)
@ricardogpsf ricardogpsf requested a review from a team as a code owner May 12, 2026 18:45
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.
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