Skip to content

[Library Bug] validation errors for Service fields.app.ServiceField.selector.app version 2026.01.1 and later #225

@konetzed

Description

@konetzed

Describe the bug
Installation method Home Assistant OS
Core 2026.2.0
Supervisor 2026.01.1
Operating System 17.0
Frontend 20260128.6

upgraded to 2026.2.0 and now api is broken

To Reproduce
Steps to reproduce the behavior:
Upgrade to 2026.2.0
Try to get domains see error below

Traceback (most recent call last):
  File "/home/konetzed/venv/ha/shed_lights.py", line 18, in <module>
    switch = client.get_domain("switch")
  File "/home/konetzed/venv/ha/lib/python3.13/site-packages/homeassistant_api/rawclient.py", line 288, in get_domain
    return self.get_domains().get(domain_id)
           ~~~~~~~~~~~~~~~~^^
  File "/home/konetzed/venv/ha/lib/python3.13/site-packages/homeassistant_api/rawclient.py", line 281, in get_domains
    return {domain.domain_id: domain for domain in domains}
                                                   ^^^^^^^
  File "/home/konetzed/venv/ha/lib/python3.13/site-packages/homeassistant_api/rawclient.py", line 278, in <lambda>
    lambda json: Domain.from_json(json, client=cast(Client, self)),
                 ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/konetzed/venv/ha/lib/python3.13/site-packages/homeassistant_api/models/domains.py", line 68, in from_json
    domain._add_service(service_id, **data)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "/home/konetzed/venv/ha/lib/python3.13/site-packages/homeassistant_api/models/domains.py", line 76, in _add_service
    service_id: Service(
                ~~~~~~~^
        service_id=service_id,
        ^^^^^^^^^^^^^^^^^^^^^^
        domain=self,
        ^^^^^^^^^^^^
        **data,
        ^^^^^^^
    )
    ^
  File "/home/konetzed/venv/ha/lib/python3.13/site-packages/pydantic/main.py", line 250, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 5 validation errors for Service
fields.app.ServiceField.selector.app
  Extra inputs are not permitted [type=extra_forbidden, input_value={}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
fields.app.ServiceFieldCollection.fields
  Field required [type=missing, input_value={'required': True, 'examp...'selector': {'app': {}}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/missing
fields.app.ServiceFieldCollection.required
  Extra inputs are not permitted [type=extra_forbidden, input_value=True, input_type=bool]
    For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
fields.app.ServiceFieldCollection.example
  Extra inputs are not permitted [type=extra_forbidden, input_value='core_ssh', input_type=str]
    For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
fields.app.ServiceFieldCollection.selector
  Extra inputs are not permitted [type=extra_forbidden, input_value={'app': {}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
(ha) konetzed@serenity ~/venv/ha $ 

The Code

(ha) konetzed@serenity ~/venv/ha $ cat shed_lights.py 
#!/home/konetzed/venv/ha/bin/python
import os

from homeassistant_api import Client

api_url = <REMOVED FOR SAFETY>  # Something like http://localhost:8123/api
token = <REMOVED FOR SAFETY>

# Used to aunthenticate yourself with homeassistant
# See the documentation on how to obtain a Long Lived Access Token

assert token is not None

with Client(
    api_url,
    token,
) as client:  # Create Client object and check that its running.
    switch = client.get_domain("switch")

    # Tells Home Assistant to trigger the toggle service on the given entity_id
    switch.toggle(entity_id="switch.shed_main_lights")

Expected behavior
It should work :)

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Debian
  • OS Version 13
  • HomeAssistantAPI Version: 5.0.2.post2
Package              Version
-------------------- -----------
aiohappyeyeballs     2.6.1
aiohttp              3.13.0
aiohttp-client-cache 0.14.1
aiosignal            1.4.0
annotated-types      0.7.0
attrs                25.4.0
cattrs               25.3.0
certifi              2025.10.5
charset-normalizer   3.4.3
frozenlist           1.8.0
HomeAssistant-API    5.0.2.post2
idna                 3.10
itsdangerous         2.2.0
multidict            6.7.0
pip                  25.1.1
platformdirs         4.4.0
propcache            0.4.0
pydantic             2.12.0
pydantic_core        2.41.1
requests             2.32.5
requests-cache       1.2.1
simplejson           3.20.2
typing_extensions    4.15.0
typing-inspection    0.4.2
url-normalize        2.2.1
urllib3              2.5.0
websockets           15.0.1
yarl                 1.22.0

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions