Skip to content

Fix Ruby SDK silently swallowing API errors (SIGN-17019)#553

Merged
adanilowski-dropbox merged 3 commits into
mainfrom
SIGN-17019-fix-ruby-sdk-error-handling
Jul 22, 2026
Merged

Fix Ruby SDK silently swallowing API errors (SIGN-17019)#553
adanilowski-dropbox merged 3 commits into
mainfrom
SIGN-17019-fix-ruby-sdk-error-handling

Conversation

@adanilowski-dropbox

@adanilowski-dropbox adanilowski-dropbox commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Title: Fix Ruby SDK error handling for server/connection errors (SIGN-17019)

Summary

  • Add nil guard on e.code before range comparison to prevent NoMethodError on timeout/connection failures
  • Re-raise unmatched ApiError exceptions so errors aren't silently swallowed
  • Add 5XX range response to all OpenAPI specs so server errors get deserialized into typed ErrorResponse objects, consistent with 4XX handling

Problem
The Ruby SDK's rescue block in generated API methods had two bugs:

  1. Timeout/connection errors crash with NoMethodError: undefined method '>=' for nil:NilClass because e.code is nil
  2. 5XX server errors are silently swallowed (method returns nil) because no range matches and the error is never re-raised

Additionally, even after fixing the re-raise, 5XX errors returned a raw string response_body while 4XX returned a typed ErrorResponse — inconsistent for SDK consumers.

Fix

  • sdks/ruby/templates/api.mustache: nil guard + raise e fallback
  • openapi-raw.yaml, openapi-sdk.yaml, openapi.yaml: add 5XX response with ErrorResponse schema to all endpoints
  • All generated Ruby API files updated to match

Test plan

  • Run integration test in Docker:
    docker run --rm -v $(pwd):/app -w /app ruby:3.2 bash -c "cd repos/ruby && gem install bundler:2.3.26 && bundle install --quiet && cd /app && ruby -I repos/ruby/lib integration_test.rb"
  • Verify 5XX errors return typed ErrorResponse body (not raw string)
  • Verify timeout/connection errors raise ApiError (not NoMethodError)
  • Confirm 4XX and 200 success paths are unaffected
  • Regenerate SDK from template and verify output matches

Add nil guard on e.code before range comparison to prevent NoMethodError
on timeout/connection failures, and re-raise unmatched ApiError exceptions
so 5XX errors propagate instead of returning nil.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@adanilowski-dropbox adanilowski-dropbox self-assigned this Jul 21, 2026
…GN-17019)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@erkkinen erkkinen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@adanilowski-dropbox
adanilowski-dropbox merged commit 05e0708 into main Jul 22, 2026
9 checks passed
@adanilowski-dropbox
adanilowski-dropbox deleted the SIGN-17019-fix-ruby-sdk-error-handling branch July 22, 2026 14:10
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