Skip to content

Fix ResoFaradayMiddleware NoMethodError on XML responses#189

Merged
atomfbs merged 2 commits intomasterfrom
Fix_ResoFaradayMiddleware_NoMethodError_on_XML_responses
May 8, 2026
Merged

Fix ResoFaradayMiddleware NoMethodError on XML responses#189
atomfbs merged 2 commits intomasterfrom
Fix_ResoFaradayMiddleware_NoMethodError_on_XML_responses

Conversation

@atomfbs
Copy link
Copy Markdown
Collaborator

@atomfbs atomfbs commented May 8, 2026

Rescue referenced unset local +body+ instead of +env[:body]+, raising NoMethodError on every non-JSON response. Adds spec coverage.

Summary

  • Rescue in ResoFaradayMiddleware#on_complete referenced the local
    body variable, but MultiJson.decode raised before body was
    assigned — leaving it nil. .strip on nil raised NoMethodError
    for every non-JSON response, including legitimate RESO XML metadata
    (/Reso/OData/$metadata).
  • Reference env[:body] (the raw body) instead.
  • Adds spec coverage: legacy D-envelope passthrough, flat OData JSON,
    XML metadata regression, and genuine non-JSON/non-XML still raising
    MultiJson::ParseError.

Test plan

  • bundle exec rspec spec/unit/spark_api/reso_faraday_middleware_spec.rb — 4/4 pass

Rescue referenced unset local +body+ instead of +env[:body]+, raising
NoMethodError on every non-JSON response. Adds spec coverage.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@atomfbs atomfbs requested a review from wlmcewen May 8, 2026 15:51
Copy link
Copy Markdown
Contributor

@wlmcewen wlmcewen left a comment

Choose a reason for hiding this comment

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

Nice work.

@atomfbs atomfbs merged commit fd881c6 into master May 8, 2026
4 checks passed
@atomfbs atomfbs deleted the Fix_ResoFaradayMiddleware_NoMethodError_on_XML_responses branch May 8, 2026 16:53
@atomfbs atomfbs restored the Fix_ResoFaradayMiddleware_NoMethodError_on_XML_responses branch May 8, 2026 17:25
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