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
73.66k stars 30.8k forks source link

Generic camera: Insufficient error message when configuration fails #112279

Closed SvenRtbg closed 7 months ago

SvenRtbg commented 8 months ago

The problem

I have created a working "still image" weather map using the generic camera. Some time ago it stoppen providing images.

Opening the configuration again, and without change saving it was not successful. It reads: "Error getting camera image from TheWeatherImageUrl: HTTPStatusError"

That's barely a sufficient error message, because there can be a ton of potential errors triggering this. I manually had to go into the config to increase the logger level to "info" to see that the server responded with 403 status.

I would very much like to see this kind of information already in the initial UI-based error display to explain "HTTPStatusError".

Alternative error situations I could imagine: Status 404, 500 or 503. It would speed up the error tracking process immensely if at least the error status code would be mentioned.

What version of Home Assistant Core has the issue?

core-2024.1.2

What was the last working version of Home Assistant Core?

core-2024.1.2

What type of installation are you running?

Home Assistant Container

Integration causing the issue

generic

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 8 months ago

Hey there @davet2001, mind taking a look at this issue as it has been labeled with an integration (generic) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `generic` 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 generic` 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)


generic documentation generic source (message by IssueLinks)

davet2001 commented 8 months ago

Hi @SvenRtbg thanks for submitting this.

I fully agree with you. Yes, let's add a better message if possible to help people when there is a specific type of connection error.

I will work on a PR to address it this weekend.

Thanks!

davet2001 commented 8 months ago

I have reproduced this using a test url e.g. http://httpstat.us/403 as a still image url. In all cases when I tried

http://httpstat.us/403 
http://httpstat.us/404
http://httpstat.us/500

I got the message

Unable to load valid image from still image URL (e.g. invalid host, URL or authentication failure). Review log for more info.

In the logs I see

2024-03-09 08:40:56.286 ERROR (MainThread) [homeassistant.components.generic.config_flow] Error getting camera image from http://httpstat.us/403: HTTPStatusError
2024-03-09 08:41:13.389 ERROR (MainThread) [homeassistant.components.generic.config_flow] Error getting camera image from http://httpstat.us/404: HTTPStatusError
2024-03-09 08:41:15.846 ERROR (MainThread) [homeassistant.components.generic.config_flow] Error getting camera image from http://httpstat.us/500: HTTPStatusError

Working on a PR now.

SvenRtbg commented 8 months ago

Can confirm this is the behaviour when adding a URL that isn't working from the beginning. And I don't like this message either, but at least it is pointing to the logs.

Consider that in my case, the URL initially worked, and then started to respond with 403.

davet2001 commented 8 months ago

Ok, just to clarify, the new behaviour after the PR is detailed here: https://github.com/home-assistant/core/pull/112814#issuecomment-1986985730

It displays more descriptive messages on the UI and the log messages include the error code.