Skip to content

Hardcoded Chrome/120 User-Agent is rejected by some feeds (403 → "cannot_connect") #7

Closed

Description

@DJGizbo

Version: A better Feedparser 1.2.0

What happens
Adding https://aidoende.nl/AI/feed.xml fails in the config flow with cannot_connect. The feed itself is valid RSS 2.0 with 30 items.

The cause is the hardcoded User-Agent in const.py:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

The site's server (Apache) blocks this outdated Chrome version and returns 403 Forbidden – Request forbidden by administrative rules. async_validate_feed then turns that into cannot_connect, so the reason is not visible to the user.

Reproduction

curl -o /dev/null -w "%{http_code}\n" -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" https://aidoende.nl/AI/feed.xml
# 403
curl -o /dev/null -w "%{http_code}\n" -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36" https://aidoende.nl/AI/feed.xml
# 200

Mozilla/5.0 on its own, feedparser's own User-Agent and Home Assistant's own User-Agent all get 200 as well. Changing only Chrome/120.0.0.0 to Chrome/140.0.0.0 in const.py fixes it locally.

Suggestions

  1. Update the default User-Agent. Better still, make it configurable in the options flow (or use an honest UA such as HomeAssistant-Feedparser/<version>), because a frozen browser string will keep going stale.
  2. Show HTTP status errors (403/404) in the config flow, instead of mapping them to cannot_connect.

Thanks for the integration!

(written with the help of AI)

Activity

  1. added a commit that references this issue on Sep 25, 2026
  2. timmaurice commented on Sep 25, 2026

    @timmaurice
    Owner

    @DJGizbo thanks a lot for this report, and for the clear reproduction with both curl commands. It made the cause easy to confirm.

    Both of your suggestions are in 1.3.0:

    • Feeds that refuse the browser string load again. The integration now presents a current Chrome, and if a server still answers with 403, it asks once more as HomeAssistant-Feedparser. That means a feed keeps working even when the browser string ages again. https://aidoende.nl/AI/feed.xml can be added now.
    • The setup dialog says what went wrong. Instead of "Failed to connect" for everything, it now tells you when the server refused access (403), needs a login (401) or has no feed at that address (404/410). The same messages appear under Reconfigure.

    Update through HACS and add the feed again; nothing else needs changing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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