Skip to content

All responses are base64 encoded #1605

@joeldentici

Description

@joeldentici

It seems that Zappa always responds with a base64 encoded string for the response body and "isBase64Encoded" set to true.

The relevant file is the "handler.py" file provided/generated by Zappa.

On line 513, we have this if statement:

if not response.mimetype.startswith("text/") \
    or response.mimetype != "application/json":

The condition's negation is:

response.mimetype.startswith("text/") and response.mimetype == "application/json"

Clearly this is a contradiction, so the condition itself is a tautology. The true branch is taken and Zappa will always base64 encode responses.

It seems that the intention of the condition is to NOT base64 encode responses that are text (but to take a conservative approach to determine what is "text").

It seems that what we want is to NOT base64 encode when this condition is true:

response.mimetype.startswith('text/') or response.mimetype == 'application/json'

If this is the case, the condition starting on line 513 should instead be:

not response.mimetype.startswith('text/') and response.mimetype != 'application/json'

I noticed this while using Zappa 0.46.2

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