Skip to content

Faraday v1 Middleware Attempts to Parse HTML Responses as JSON Resulting in Faraday::ParsingError #632

@sshaw

Description

@sshaw

Describe the bug

Faraday middleware attempts to parse HTML responses as JSON. This occurs when Cloudflare (in front of the API) returns HTML, leading to a Faraday::ParsingError

To Reproduce
Steps to reproduce the behavior:

Stems from Cloudfare's upstream connection issues to OpenAI. Not sure how to reproduce.

Expected behavior

No Faraday::ParsingError

Additional context

Relevant line:

f.response :json

This gem allows Faraday v1 and v2. For v1 parsing requires Faraday Middleware. When using this one must specify the content type when including the middleware.
When no content type is set the v1 middleware will try to parse everything. Faraday v2 does not have this problem.

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