Skip to content

Fix update_available when it is disabled#1680

Merged
frenck merged 1 commit intofrenck:mainfrom
mib1185:fix-update-is-disabled
Nov 16, 2025
Merged

Fix update_available when it is disabled#1680
frenck merged 1 commit intofrenck:mainfrom
mib1185:fix-update-is-disabled

Conversation

@mib1185
Copy link
Copy Markdown
Collaborator

@mib1185 mib1185 commented Nov 16, 2025

Proposed Changes

on docker installation types, the auto update mechanism is disabled via cli option (see here), but this results in a response, that only contains the disabled key, so we need to default all other properties to None

related error (it's on my dev, but PR for HA is incoming)

2025-11-16 10:31:27.441 ERROR (MainThread) [homeassistant.components.update] Error while setting up adguard platform for update: AdGuardHomeAvailableUpdate.__init__() missing 4 required positional arguments: 'new_version', 'announcement', 'announcement_url', and 'can_autoupdate'
Traceback (most recent call last):
  File "/workspaces/homeassistant-core/homeassistant/helpers/entity_platform.py", line 451, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/workspaces/homeassistant-core/homeassistant/components/adguard/update.py", line 31, in async_setup_entry
    if (await data.client.update.update_available()).disabled:
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/ha-venv/lib/python3.13/site-packages/adguardhome/update.py", line 40, in update_available
    return AdGuardHomeAvailableUpdate(**response)
TypeError: AdGuardHomeAvailableUpdate.__init__() missing 4 required positional arguments: 'new_version', 'announcement', 'announcement_url', and 'can_autoupdate'

Related Issues

(Github link to related issues or pull requests)

Copilot AI review requested due to automatic review settings November 16, 2025 10:30
@mib1185 mib1185 added the bugfix Inconsistencies or issues which will cause a problem for users or implementers. label Nov 16, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Nov 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.70%. Comparing base (11f5f58) to head (9a19a27).
⚠️ Report is 737 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##              main    #1680      +/-   ##
===========================================
- Coverage   100.00%   99.70%   -0.30%     
===========================================
  Files            9       10       +1     
  Lines          316      341      +25     
  Branches        26       16      -10     
===========================================
+ Hits           316      340      +24     
- Partials         0        1       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug where the AdGuardHome client couldn't properly handle API responses when auto-update is disabled (common in Docker installations). When updates are disabled, the API returns only {"disabled": true} without the other update-related fields.

  • Modified AdGuardHomeAvailableUpdate dataclass to make new_version, announcement, announcement_url, and can_autoupdate optional with None defaults
  • Added comprehensive test coverage for the disabled update scenario

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/adguardhome/update.py Updated dataclass fields to be optional (except disabled), allowing proper instantiation when API returns minimal response
tests/test_update.py Added test case to verify correct handling of disabled auto-update scenario

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Owner

@frenck frenck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @mib1185 👍

../Frenck

                       

Blogging my personal ramblings at frenck.dev

@frenck frenck merged commit e188246 into frenck:main Nov 16, 2025
23 of 24 checks passed
@mib1185 mib1185 deleted the fix-update-is-disabled branch November 16, 2025 10:35
@github-actions github-actions bot locked and limited conversation to collaborators Nov 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bugfix Inconsistencies or issues which will cause a problem for users or implementers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants