8000 `/api/handle/intent` throws 500 with no helpful info · Issue #139440 · home-assistant/core · GitHub
[go: up one dir, main page]

Skip to content
/api/handle/intent throws 500 with no helpful info #139440
@Ramblurr

Description

@Ramblurr

The problem

I am building my own conversation agent that lives outside HA. My agent needs to be able to send intents to HA to take actions. The /api/handle/intent endpoint looks perfect, but unfortunately isn't that useful.

If I make a POST with the payload:

{"name":"HassTurnOff","data":{"name":"Office Overhead"}}

I get back a text response with status 500 error:

500 Internal Server Error


Server got itself in trouble

Looking at the HA logs shows:

homeassistant.helpers.intent.MatchFailedError: 
    MatchFailedError(
        result=MatchTargetsResult(
            is_match=False,
            no_match_reason=<MatchFailedReason.DUPLICATE_NAME: 11>,
            states=[],
            no_match_name='Office Overhead',
            areas=[],
            floors=[]
        ),
        constraints=MatchTargetsConstraints(
            name='Office Overhead',
            area_name=None,
            floor_name=None,
            domains=None,
            device_classes=None,
            features=None,
            states=None,
            assistant=None,
            allow_duplicate_names=False
        ),
        preferences=MatchTargetsPreferences(
            area_id=None,
            floor_id=None
        )
    )

I think that's a reasonable error that should be sent back to the caller as a 4xx error. In my case I have a switch and a light called "office overhead", hence the duplicate match.

Could this endpoint be improved? Or is there another reason it is as it is now?

👉 Here is the full log entry
Logger: aiohttp.server
Source: /usr/local/lib/python3.13/site-packages/aiohttp/web_protocol.py:451
First occurred: 4:27:03 PM (1 occurrences)
Last logged: 4:27:03 PM
Error handling request

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/aiohttp/web_protocol.py", line 480, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/web_app.py", line 569, in _handle
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 86, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper
    return await method(view, request, data, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/intent/__init__.py", line 478, in post
    intent_result = await intent.async_handle(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
        hass, DOMAIN, intent_name, slots, "", self.context(request)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/intent.py", line 144, in async_handle
    result = await handler.async_handle(intent)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/intent.py", line 983, in async_handle
    raise MatchFailedError(
    ...<3 lines>...
    )
homeassistant.helpers.intent.MatchFailedError: <MatchFailedError result=MatchTargetsResult(is_match=False, no_match_reason=<MatchFailedReason.DUPLICATE_NAME: 11>, states=[], no_match_name='Office Overhead', areas=[], floors=[]), constraints=MatchTargetsConstraints(name='Office Overhead', area_name=None, floor_name=None, domains=None, device_classes=None, features=None, states=None, assistant=None, allow_duplicate_names=False), preferences=MatchTargetsPreferences(area_id=None, floor_id=None)>

What version of Home Assistant Core has the issue?

core-2025.3.0.dev0

What was the last working version of Home Assistant Core?

n/a

What type of installation are you running?

Home Assistant OS

Integration causing the issue

intent

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

Anything in the logs that might be useful for us?

Additional information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0