Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: add response HTTP code when there is an error #3

Open
DutchessNicole opened this issue Sep 4, 2024 · 2 comments
Open

Comments

@DutchessNicole
Copy link

When a text is sent to HA, there is only the response text returned in the logs of wirepod.

This makes it very difficult to figure out what is happening when that response is missing, such as when the access token is wrong (401), when the request is wrong (400) or another error happens. In both these cases there's no response text at all.

Would it be possible to return the HTTP response code when there is a non-200 status code? It would help immensely in debugging issues.

@NonaSuomy
Copy link
Owner

**Note:** _Uncommenting AgentID stuff in the code is not required to use the default HA agent! It is an optional setting when you have multiple agents that are not the default agent in Home Assistant. Uncommenting these in the go code and not setting the AgentID properly may give you HTML status codes that you can't see and may not work. Test the default agent before using this._

Added this note, not sure about the second question, where are you seeing the html status code?

@DutchessNicole
Copy link
Author

When you perform the HTTP request you will get a status code from the HA instance, or the proxy it connects to.
Currently you only report the response text in the log, but with a 4xx error there won't be one, so we can't know what happened to the request.
It would be nice to report the HTTP status code, as well as any possible response. So that in case of an error you can see in the logs that your request was faulty or any other status as well (like a 5xx error indicating that HA is having issues itself.)

See https://datatracker.ietf.org/doc/html/rfc7231#page-48 for the possible status codes. Note that we don't need all of these:
2xx codes indicate success, so you'd only need to add the code itself.
3xx codes should be transparent and probably won't need any special treatment either
only 4xx and 5xx codes indicate errors: 4xx means the request is invalid in some way, 5xx means the responding server has issues. Those are the important ones to know about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants