home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70.25k stars 29.24k forks source link

Mobile App notification regression, "Attempt to decode JSON with unexpected mimetype" #119419

Open relyef opened 1 month ago

relyef commented 1 month ago

The problem

After update to 2024.6.2 mobile app notification to clear message fails with "Attempt to decode JSON with unexpected mimetype" error. Prior to the update, notification worked with no issues for a very long time.

Related Automation action (clear notification about mailbox cover being opened)

        sequence:
          - delay:
              hours: 0
              minutes: 0
              seconds: 5
              milliseconds: 0
          - service: notify.all_phones
            data:
              message: clear_notification
              data:
                tag: us-mail
                ttl: 0
                priority: high

Trace information confirms automation was triggered but the phone never received the "clear" notification.

Corresponding log message:

Logger: homeassistant.components.mobile_app.notify
Source: components/mobile_app/notify.py:204
integration: Mobile App ([documentation](https://www.home-assistant.io/integrations/mobile_app), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+mobile_app%22))
First occurred: 11:08:26 AM (1 occurrences)
Last logged: 11:08:26 AM
Error sending notification to https://mobile-apps.home-assistant.io/api/sendPush/android/v1: ContentTypeError(RequestInfo(url=URL('https://mobile-apps.home-assistant.io/api/sendPush/android/v1'), method='POST', headers=<CIMultiDictProxy('Host': 'mobile-apps.home-assistant.io', 'User-Agent': 'HomeAssistant/2024.6.2 aiohttp/3.9.5 Python/3.12', 'Accept': '*/*', 'Accept-Encoding': 'gzip, deflate, br', 'Content-Length': '466', 'Content-Type': 'application/json')>, real_url=URL('https://mobile-apps.home-assistant.io/api/sendPush/android/v1')), (), message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8', headers=<CIMultiDictProxy('Connection': 'close', 'Content-Length': '452', 'Server': 'Varnish', 'Retry-After': '0', 'Content-Type': 'text/html; charset=utf-8', 'Accept-Ranges': 'bytes', 'Date': 'Tue, 11 Jun 2024 18:08:26 GMT', 'X-Served-By': 'cache-pao-kpao1770078-PAO', 'X-Cache': 'MISS', 'X-Cache-Hits': '0', 'X-Timer': 'S1718129306.279517,VS0,VE58', 'alt-svc': 'h3=":443";ma=86400,h3-29=":443";ma=86400,h3-27=":443";ma=86400')>)

What version of Home Assistant Core has the issue?

core-2024.6.2

What was the last working version of Home Assistant Core?

core-2024.6.1

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Automation, calling service.nofity with clear_notification message

Link to integration documentation on our website

https://www.home-assistant.io/integrations/mobile_app/

Diagnostics information

No response

Example YAML snippet

sequence:
          - delay:
              hours: 0
              minutes: 0
              seconds: 5
              milliseconds: 0
          - service: notify.all_phones
            data:
              message: clear_notification
              data:
                tag: us-mail
                ttl: 0
                priority: high

Anything in the logs that might be useful for us?

Logger: homeassistant.components.mobile_app.notify
Source: components/mobile_app/notify.py:204
integration: Mobile App (documentation, issues)
First occurred: 11:08:26 AM (1 occurrences)
Last logged: 11:08:26 AM
Error sending notification to https://mobile-apps.home-assistant.io/api/sendPush/android/v1: ContentTypeError(RequestInfo(url=URL('https://mobile-apps.home-assistant.io/api/sendPush/android/v1'), method='POST', headers=<CIMultiDictProxy('Host': 'mobile-apps.home-assistant.io', 'User-Agent': 'HomeAssistant/2024.6.2 aiohttp/3.9.5 Python/3.12', 'Accept': '*/*', 'Accept-Encoding': 'gzip, deflate, br', 'Content-Length': '466', 'Content-Type': 'application/json')>, real_url=URL('https://mobile-apps.home-assistant.io/api/sendPush/android/v1')), (), message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8', headers=<CIMultiDictProxy('Connection': 'close', 'Content-Length': '452', 'Server': 'Varnish', 'Retry-After': '0', 'Content-Type': 'text/html; charset=utf-8', 'Accept-Ranges': 'bytes', 'Date': 'Tue, 11 Jun 2024 18:08:26 GMT', 'X-Served-By': 'cache-pao-kpao1770078-PAO', 'X-Cache': 'MISS', 'X-Cache-Hits': '0', 'X-Timer': 'S1718129306.279517,VS0,VE58', 'alt-svc': 'h3=":443";ma=86400,h3-29=":443";ma=86400,h3-27=":443";ma=86400')>)

Additional information

Was working prior to 2024.6.2 update

home-assistant[bot] commented 1 month ago

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (mobile_app) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `mobile_app` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign mobile_app` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


mobile_app documentation mobile_app source (message by IssueLinks)

relyef commented 1 month ago

When the same script is called via Developer Tools/Services, everything works as expected:

service: notify.all_phones
data:
  message: clear_notification
  data:
    tag: us-mail
    ttl: 0
    priority: high
dshokouhi commented 1 month ago

we just pushed a server fix for FCM are you still able to reproduce it today?

relyef commented 1 month ago

Unfortunately, no. The automation to clear the message worked successfully