Skip to content

Handle Bynder server errors when fetching assets #40

@alxbridge

Description

@alxbridge

Currently the download_file() method doesn't check the response code from its call to Bynder with requests.get(). This means that if Bynder returns an error response for any reason, the contents of this response are handled and saved as if they're the image asset expected.

This can then lead to unexpected problems if the error response contains HTML markup: in at least some instances the call to mimetypes.guess_type() incorrectly identifies the stored response as an SVG image. This causes server errors when attempting to create renditions in the image library, or if the 'image' is inserted to a page. See the attached file for an example where this has happened.

(Not an) svg file

Expected behaviour: Error responses are caught and surfaced to content editors with an appropriate message. No asset is stored as a result of failed requests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions