Skip to content

HTTP::Error raised on text/plain response hides raw Expo response #17

@donni106

Description

@donni106

We are using expo-server-sdk 0.1.6 together with http 5.3.1 in a Rails / Sidekiq production setup.

We hit an intermittent failure while sending push notifications:

HTTP::Error: Unknown MIME type: text/plain

Did you ever see this before?

The exception appears to come from the response parsing path inside the gem, specifically where response.parse is called in lib/push/client.rb.

From what we can see, the problem is not necessarily the push request itself, but the response parsing step:

  • the notification may already have been accepted by Expo
  • but if the upstream response has Content-Type: text/plain, the http gem raises before the raw response can be inspected
  • as a result, applications cannot see the actual response status, headers, or body

This makes production debugging difficult, especially for transient upstream/proxy/CDN issues.

Expected behavior:

  • either handle unexpected content types more gracefully
  • or raise a gem-specific error that includes access to the raw HTTP response
  • or allow callers to inspect status, headers, and body before JSON parsing happens

Suggested improvement:

  • rescue HTTP::Error around response.parse
  • include response metadata in the raised error if possible
  • optionally fall back to reading response.to_s and raising a more descriptive Expo::Push::ServerError

A minimal improvement would already be very helpful:

  • expose the response status
  • expose the Content-Type
  • expose the raw body snippet

That would let applications distinguish between:

  • actual Expo API errors
  • transient proxy/CDN/network issues
  • malformed or unexpected upstream responses

I would be very happy to collaborate on this, and I am available for any follow-up questions at any time and can respond quickly on short notice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions