Skip to content

AppDaemon returns error 500 on POST with empty body #2611

@5nafu

Description

@5nafu

Issue

If an AppDaemon app is send a POST request with an empty body, the AppDaemon itself will fail with an error 500 "An Error occurred while processing request" before even calling the app. This probably is related to the JSON parsing failing.

Background

In my Caravan, I would like to allow my Laptop to get the current location for web pages like google maps. I already have a home assistant instance running with a sensor supplying GPS coordinates and an App in AppDaemon that will output said coordinates in a format understood by firefox. Setting the geo.provider.network.url to the app endpoint works kindof.

Unfortunately Firefox sends a POST request with an empty body as seen on https://webhook.site/#!/view/dabafb95-bc37-4064-a111-6a1cfdb21b01/b6be3890-766a-451a-8cb6-4836185e41ae .

On

args = await request.json()
, the AppDaemon will always try to parse the body as JSON which obviously fails.

Possible solution?

If you agree to accept this as a bug, a check if there is a body might be a simple fix. Maybe something like

args = await request.json() if request.can_read_body else null

could do the trick?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions