Skip to content

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

Open
ricardogpsf wants to merge 3 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 3 commits into
aws:version-3from
ricardogpsf:fix/neptunedata-detailed-message-ruby-3-2-compat

Conversation

@ricardogpsf
Copy link
Copy Markdown

@ricardogpsf ricardogpsf commented May 12, 2026

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) (code here), which calls e.full_message(highlight: false, order: :top) (code here) to capture the stacktrace. This silently breaks tracing and any instrumentation that records 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
Ricardo Galeno added 2 commits May 12, 2026 18:43
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.
The RBS generator was producing `() -> ::String` for the detailed_message
member, but after the Ruby 3.2+ fix the method signature is now
`def detailed_message(highlight: true, **)`. Update the RBS generator
to emit `(?highlight: bool) -> ::String` for members named
detailed_message, consistent with the generated sig/errors.rbs.
@jterapin
Copy link
Copy Markdown
Contributor

Hey, thanks for the PR! This is a tricky case where we have a name collision between an API member name and a Ruby built-in method. The fix as proposed will still always return the API member value; meaning when Ruby's full_message calls detailed_message(highlight: true) internally, it will render the API member value rather than Ruby's formatted error message output.

We are currently looking into a few different solutions and will circle back with a resolution.

@ricardogpsf
Copy link
Copy Markdown
Author

ricardogpsf commented May 13, 2026

Hey, thanks for the PR! This is a tricky case where we have a name collision between an API member name and a Ruby built-in method. The fix as proposed will still always return the API member value; meaning when Ruby's full_message calls detailed_message(highlight: true) internally, it will render the API member value rather than Ruby's formatted error message output.

We are currently looking into a few different solutions and will circle back with a resolution.

NP, thanks for the feedback. Actually this PR should be a draft since I still have no good solution, and realized (as you said) doing those changes will not solve the issue properly but just silence a not ideal behavior (at least would not break the code). I'm patching it in my application since it's braking there.
Anyway, was good you already seen it and you're already working on it too. Thank you for it. I'll close this PR then. Do you want me opening an Issue just for tracking and other people would be able to know you're aware of it?

@jterapin
Copy link
Copy Markdown
Contributor

Yes please to closing the pr and creating an issue. That would be great. I will post updates in the issue once we come to a resolution.

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.

2 participants