hassio-addons / addon-adguard-home

AdGuard Home - Home Assistant Community Add-ons
https://addons.community
MIT License
388 stars 48 forks source link

cannot change settings in 4.7.5 #359

Closed r100gs closed 1 year ago

r100gs commented 1 year ago

Problem/Motivation

change settings on webpage

(Why the issue was filed) get error

Expected behavior

set or remove hook (What you expected to happen) cann klick and set hook or remove

Actual behavior

get error (What actually happened) get a red error 2022/11/07 16:53:19.228542 [error] POST 192.168.xx.xx:8123 /control/safebrowsing/enable: empty body with content-type "application/octet-stream" not allowed

Steps to reproduce

go to allgemeine einstellungen try to change settings (How can someone else make/see it happen) see above

Proposed changes

(If you have a proposed change, workaround or fix, describe the rationale behind it)

I tried with HA 2022.10.5 and 2022.11.1, was working in 4.7.4

image
stevnhoved commented 1 year ago

I get the same error when clearing query log or statistics

itsboo07 commented 1 year ago

same here after updating

bakito commented 1 year ago

I'm also facing some content-type issues with 4.7.5 in the adguardhome-sync tool. https://github.com/bakito/adguardhome-sync/issues/121 Here the issue is, that the content-type of apu json requests is now text/plain; charset=utf-8 instead of application/json. As it also has to do with content-type, it might be related. 4.7.4 was working fine.

bakito commented 1 year ago

There seems to be an issue in adguardhome itself. https://github.com/AdguardTeam/AdGuardHome/issues/5116

junado commented 1 year ago

Updated to 2022.11.2 and the issue is still there. I'm running a new install of AdGuard on the latest HA.

System Information

version core-2022.11.2
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.10.7
os_name Linux
os_version 5.15.61-v8
arch aarch64
timezone America/Toronto
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 5000 Installed Version | 1.28.3 Stage | running Available Repositories | 1140 Downloaded Repositories | 21
Home Assistant Cloud logged_in | true -- | -- subscription_expiration | 1 décembre 2022 à 19:00 relayer_connected | true remote_enabled | true remote_connected | true alexa_enabled | true google_enabled | true remote_server | us-east-1-3.ui.nabu.casa can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 9.3 -- | -- update_channel | stable supervisor_version | supervisor-2022.10.2 agent_version | 1.4.1 docker_version | 20.10.18 disk_total | 219.4 GB disk_used | 83.0 GB healthy | true supported | true board | rpi4-64 supervisor_api | ok version_api | ok installed_addons | Studio Code Server (5.4.0), ESPHome (2022.10.2), SSH & Web Terminal (12.1.2), SQLite Web (3.6.1), Terminal & SSH (9.6.1), InfluxDB (4.5.0), Grafana (8.0.2), AirCast (3.5.0), Home Assistant Google Drive Backup (0.109.1), AdGuard Home (4.7.5), Samba share (10.0.0)
Dashboards dashboards | 1 -- | -- resources | 14 views | 4 mode | storage
Recorder oldest_recorder_run | 31 octobre 2022 à 18:24 -- | -- current_recorder_run | 9 novembre 2022 à 08:56 estimated_db_size | 666.28 MiB database_engine | sqlite database_version | 3.38.5
Spotify api_endpoint_reachable | ok -- | --
snapsl commented 1 year ago

v0.107.15 introduced a new content type policy. I think this causes the problem. (https://github.com/AdguardTeam/AdGuardHome/releases/tag/v0.107.15)

Here https://github.com/hassio-addons/addon-adguard-home/blob/88a61938785724eb5a5557a25e33d440dc168261/adguard/rootfs/etc/nginx/nginx.conf#L32

sysadmin-info commented 1 year ago

I have exactly the same issue. I cannot clear the cache in Adguard Home Addon in Home Assistant Supervised version: Home Assistant 2022.11.2 Supervisor 2022.10.2 Frontend 20221108.0 - latest Error: Error: control/stats_reset | empty body with content-type "application/octet-stream" not allowed | 415 Adguard Home Addon for Home Assistant Supervised: Version: v0.107.17

stevnhoved commented 1 year ago

The problem also has an affect1 on the integration The following switches just flips back again.

image

hall757 commented 1 year ago

This seems to be a UI issue. I can enable/disable the features with curl after I extract my auth cookie and the exact URL from my browser session.

curl -H content-type:application/json \
     -H cookie:ingress_session=extracted_from_authenticated_browser_session  \
     -X POST http://myhost:8123/api/hassio_ingress/session_id/control/safebrowsing/enable \
     -d "{}"

The parts missing from the UI are a content-type of application/json and an empty json payload (which is different than an empty payload).

21Development commented 1 year ago

I'm having the same issue. Is there anything you need to help reproduce / fix?

whwar9739 commented 1 year ago

I did find that if I update the Web interface port to be available: image

and I navigated to https://homeassistant.local:3000/ and logged in with my HA credentials that I can then change the settings without issue.

image

itsboo07 commented 1 year ago

@whwar9739 nice catch.. this works for now... looks like default tcp is broken with update or ha using the default tcp port

21Development commented 1 year ago

This issue doesnt seem to be assigned to anyone and the Adguard team closed it as invalid https://github.com/AdguardTeam/AdGuardHome/issues/5116 - @frenck as your listed on the HA addon page, can you help? Where should this issue be posted to get resolved?

KruseLuds commented 1 year ago

5116 still applies it is just marked as a dupe of this one; I did a search for nginx.conf on my machine and found several which had this line:

default_type        application/octet-stream;

I changed them al to:

default_type        plain/text;

restarted HA, got the same error messages about not being able to turn on the three check as listed in my issue, then rebooted the rpi and still had the same issue, then looked again in the nginx.conf files and they had all changed back to "application/octet-stream;"

hall757 commented 1 year ago

As I posted a few days ago, this can be fixed in the UI. Instead of relying on default content types, the javascript that makes the api call needs to explicitly set the content type to "application/json" AND send an empty json payload of "{}". I was able to reproduce the failure using defaults and a success using the above changes. If the adguard team doesn't care about supporting the product behind a proxy, I can understand why the would close the case. For me, I know how to correctly make the api call and can deal with the minor inconvenience.

sysadmin-info commented 1 year ago

Dear Randy Hall,

Can you provide a step by step solution, please?

Kind regards

Adrian Ambroziak

On Mon, Nov 14, 2022 at 8:29 PM Randy Hall @.***> wrote:

As I posted a few days ago, this can be fixed in the UI. Instead of relying on default content types, the javascript that makes the api call needs to explicitly set the content type to "application/json" AND send an empty json payload of "{}". I was able to reproduce the failure using defaults and a success using the above changes. If the adguard team doesn't care about supporting the product behind a proxy, I can understand why the would close the case. For me, I know how to correctly make the api call and can deal with the minor inconvenience.

— Reply to this email directly, view it on GitHub https://github.com/hassio-addons/addon-adguard-home/issues/359#issuecomment-1314267774, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFULAOTG3UP3UGD65DOJAODWIKHIZANCNFSM6AAAAAARZLAA5Y . You are receiving this because you commented.Message ID: @.***>

itsboo07 commented 1 year ago

@hall757 can you elaborate how to fix the issue you mentioned above?

hall757 commented 1 year ago

I took a quick look at the code. It appears that the api spec itself just needs to define that post body should be "{}" and the content-type should be "application-json" I'm sure the real culprit is the home assistant ingress changing the headers in a way that breaks adguard.

Here is my guess. I don't have a build env setup to test this.

https://github.com/AdguardTeam/AdGuardHome/blob/master/openapi/openapi.yaml

--- openapi.yaml.old 2022-11-15 11:07:12.048079000 -0500 +++ openapi.yaml 2022-11-15 15:13:51.957002996 -0500 @@ -633,6 +633,12 @@

On Tue, Nov 15, 2022 at 1:32 PM itsboo07 @.***> wrote:

@hall757 https://github.com/hall757 can you elaborate how to fix the issue you mentioned above?

— Reply to this email directly, view it on GitHub https://github.com/hassio-addons/addon-adguard-home/issues/359#issuecomment-1315711688, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWHZIPU2H6CHS26QERTPDTWIPJLRANCNFSM6AAAAAARZLAA5Y . You are receiving this because you were mentioned.Message ID: @.***>

-- Randy Hall

daverupe commented 1 year ago

So is anyone looking into fixing this issue? I have the same problem.

hall757 commented 1 year ago

This had no effect when rebuilding. Although it didn't hurt. Since whwar9739 reported this working when directly exposing the container port, I'm going to point the finger at the HA ingress.

On Tue, Nov 15, 2022 at 3:19 PM Randy Hall @.***> wrote:

I took a quick look at the code. It appears that the api spec itself just needs to define that post body should be "{}" and the content-type should be "application-json" I'm sure the real culprit is the home assistant ingress changing the headers in a way that breaks adguard.

Here is my guess. I don't have a build env setup to test this.

https://github.com/AdguardTeam/AdGuardHome/blob/master/openapi/openapi.yaml

--- openapi.yaml.old 2022-11-15 11:07:12.048079000 -0500 +++ openapi.yaml 2022-11-15 15:13:51.957002996 -0500 @@ -633,6 +633,12 @@

  • 'safebrowsing' 'operationId': 'safebrowsingEnable' 'summary': 'Enable safebrowsing'
    • 'requestBody':
    • 'required': true
    • 'content':
    • 'application/json':
    • 'schema':
    • '$ref': '#/components/schemas/EmptyBody' 'responses': '200': 'description': 'OK.' @@ -642,6 +648,12 @@
  • 'safebrowsing' 'operationId': 'safebrowsingDisable' 'summary': 'Disable safebrowsing'
    • 'requestBody':
    • 'required': true
    • 'content':
    • 'application/json':
    • 'schema':
    • '$ref': '#/components/schemas/EmptyBody' 'responses': '200': 'description': 'OK.' @@ -671,6 +683,12 @@
  • 'parental' 'operationId': 'parentalEnable' 'summary': 'Enable parental filtering'
    • 'requestBody':
    • 'required': true
    • 'content':
    • 'application/json':
    • 'schema':
    • '$ref': '#/components/schemas/EmptyBody' 'responses': '200': 'description': 'OK.' @@ -680,6 +698,12 @@
  • 'parental' 'operationId': 'parentalDisable' 'summary': 'Disable parental filtering'
    • 'requestBody':
    • 'required': true
    • 'content':
    • 'application/json':
    • 'schema':
    • '$ref': '#/components/schemas/EmptyBody' 'responses': '200': 'description': 'OK.' @@ -712,6 +736,12 @@
  • 'safesearch' 'operationId': 'safesearchEnable' 'summary': 'Enable safesearch'
    • 'requestBody':
    • 'required': true
    • 'content':
    • 'application/json':
    • 'schema':
    • '$ref': '#/components/schemas/EmptyBody' 'responses': '200': 'description': 'OK.' @@ -721,6 +751,12 @@
  • 'safesearch' 'operationId': 'safesearchDisable' 'summary': 'Disable safesearch'
    • 'requestBody':
    • 'required': true
    • 'content':
    • 'application/json':
    • 'schema':
    • '$ref': '#/components/schemas/EmptyBody' 'responses': '200': 'description': 'OK.' @@ -1243,6 +1279,9 @@ '$ref': '#/components/schemas/RewriteEntry' 'required': true 'schemas':
    • 'EmptyBody':
    • 'type': 'object'
    • 'nullable': true 'ServerStatus': 'type': 'object' 'description': 'AdGuard Home server status and configuration'

On Tue, Nov 15, 2022 at 1:32 PM itsboo07 @.***> wrote:

@hall757 https://github.com/hall757 can you elaborate how to fix the issue you mentioned above?

— Reply to this email directly, view it on GitHub https://github.com/hassio-addons/addon-adguard-home/issues/359#issuecomment-1315711688, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWHZIPU2H6CHS26QERTPDTWIPJLRANCNFSM6AAAAAARZLAA5Y . You are receiving this because you were mentioned.Message ID: @.***>

-- Randy Hall

-- Randy Hall

zeerox72 commented 1 year ago

I have the same problem. Dear @hall757 or anyone else, can you provide a step by step solution, please?

Best regards Marko M.

kcb064 commented 1 year ago

Same issue here.

PCServices2 commented 1 year ago

Same problem here. Need a fix for it for two installations.

fokcuk commented 1 year ago

confirming an issue as well, to keep track =)

KruseLuds commented 1 year ago

Agreed, same here I am very surprised they were able to release that version with such an obvious bug - !

dav-par commented 1 year ago

I did find that if I update the Web interface port to be available: image

and I navigated to https://homeassistant.local:3000/ and logged in with my HA credentials that I can then change the settings without issue.

image

where are you updating the port? I don't seem to have this menu/setting

rschuetzler commented 1 year ago

where are you updating the port? I don't seem to have this menu/setting

It's on the Add-on configuration page (https://homeassistant.local:XXXX/hassio/dashboard, click AdGuard Home, then go to the Configuration tab). I had a switch to how disabled ports that showed the Web interface box.

dav-par commented 1 year ago

where are you updating the port? I don't seem to have this menu/setting

It's on the Add-on configuration page (https://homeassistant.local:XXXX/hassio/dashboard, click AdGuard Home, then go to the Configuration tab). I had a switch to how disabled ports that showed the Web interface box.

amazing, thank you, not sure I missed that the first time round.

This worked for me too.

enduser105 commented 1 year ago

Same issue. Yes, using the direct link https://homeassistant.local:3000/ works as a temp fix but, it's not exactly convenient. Just wondering when a permanent fix will be available via auto update.

stamandr commented 1 year ago

Same issue for me on two separate installs of HA and AdGuard

stamandr commented 1 year ago

Just rolled back to 4.7.4. Works perfectly....

junado commented 1 year ago

Just rolled back to 4.7.4. Works perfectly....

Care to share how you did ? I could not find a way to downgrade. I do not have a previous installation at 4.7.4, since I first installed 4.7.5.

larena1 commented 1 year ago

Problem is that aiohttp defaults to application/octet-stream when no content type is set and that affects everything that passes ingress

stamandr commented 1 year ago

Just rolled back to 4.7.4. Works perfectly....

Care to share how you did ? I could not find a way to downgrade. I do not have a previous installation at 4.7.4, since I first installed 4.7.5.

I restored 4.7.4 from a backup.

enduser105 commented 1 year ago

Sorry for the late respone....luckily I had a backup and restored back to 4.7.0 and everything works fine now :).

junado commented 1 year ago

Thanks, that's about as straightforward as possible ;) Won't work for me since my first installed version is 4.7.5.

cleo-4 commented 1 year ago

hopefully, it will be fixed in the next update 🤞

larena1 commented 1 year ago

The problem is with ingress and more specifically with aiohttp and not with the addon so better not expect too much unless adguard takes back the change

zeehio commented 1 year ago

Thanks @larena1 for pointing towards ingress. I submitted a pull request to the supervisor that should fix this issue. However I haven't been able to test it yet and I don't know when I will be able to.

Assuming the CI checks pass, if anyone is willing to test it, it may speed up the review process. It's a one line change but it still could introduce a regression so please test it only if you are prepared for restoring your installation from a backup

larena1 commented 1 year ago

Didn't know there is a parameter but I suppose that should fix it. You might need to add this also to core though.

zeehio commented 1 year ago

Didn't know there is a parameter but I suppose that should fix it. You might need to add this also to core though.

To my understanding the request from my browser goes to ingress, that checks the auth header and forwards the request to the add-on, without involving core. But I guess we'll find that out once we test it. Hopefully I'll find some time this week to do a quick test

larena1 commented 1 year ago

Didn't know there is a parameter but I suppose that should fix it. You might need to add this also to core though.

To my understanding the request from my browser goes to ingress, that checks the auth header and forwards the request to the add-on, without involving core. But I guess we'll find that out once we test it. Hopefully I'll find some time this week to do a quick test

https://github.com/home-assistant/core/blob/dev/homeassistant/components/hassio/ingress.py

enduser105 commented 1 year ago

I have another machine with a fresh HA install and same Adguard issue. I'm happy to test if someone can tell me how to make the appropriate change. I'm assuming I would just need to somehow replace my ingress.py file with the modified one listed on the link above. If true, what's the easist way to do that (sorry, I'm still learning).

wotography commented 1 year ago

thanks for pointing me here. I’m having the same issue as well.

zeehio commented 1 year ago

Thanks again @larena1 for the accurate pointer to the home assistant core ingress component. As you said, both supervisor and core needed to be fixed.

I have submitted both pull requests and I tested them locally by manually editing both files in their respective docker containers.

I wish I had clear step by step instructions to test this, basically I used the internal "SSH and web terminal" add-on in unprotected mode (so I get docker access), from there I entered the containers and edited the source files directly. You can try to do that if you know how to use those commands, but it is not a robust approach for testing. Besides, since sources are modified, home assistant shows a warning of the system being unsupported, so apply this patches manually at your own risk.

zeehio commented 1 year ago

This issue is fixed by merging these two pull requests:

@larena1 gave me details of what and where to look, and I was able to provide a fix and test it. Now it is time for others to review and sponsor those pull requests so they get the right attention and get merged soon.

Thanks to all of you who provided all the hints for this to be fixed!

frenck commented 1 year ago

@zeehio I've marked your comment on code modifications in containers. No-one should ever do that. Please realize that most people following such instructions have no idea what they are doing and mostly end up with bigger issues.

zeehio commented 1 year ago

@zeehio I've marked your comment on code modifications in containers. No-one should ever do that. Please realize that most people following such instructions have no idea what they are doing and mostly end up with bigger issues.

Thanks, you are right. My apologies. I edited the comment so anyone who reads it can consider applying the fix if they know how and at their own risk, but specific commands to be followed blindly usually cause more harm than good as you say, so I've removed them. Feel free to offtopic this message and your last one as well if you feel like it.

zeehio commented 1 year ago

With both pull requests merged, this issue should be fixed by updating to the next (not yet released) home assistant and supervisor releases. Both home assistant core and the supervisor will have to be upgraded.

frenck commented 1 year ago

Yeah, we discussed it yesterday with some core members. We've merged it now, and are going to put it to the practical test with the upcoming nightly builds. If those do not raise new issues, we will consider marking it for a Core patch release and a next push of the Supervisor.