home-assistant/core · error · UnknownUser
UnknownUser
Error message
UnknownUser
What it means
Home Assistant raises UnknownUser when a service call context carries a user_id that no longer resolves to a user in hass.auth. In the assist_satellite ask_question handler, the user record is fetched with hass.auth.async_get_user(call.context.user_id) and a None result triggers this error. It means the acting user was deleted or the context was fabricated/stale after the call was already accepted by the service layer.
Source
Thrown at homeassistant/components/assist_satellite/__init__.py:113
vol.Optional("start_media_id"): _media_id_validator,
vol.Optional("preannounce", default=True): bool,
vol.Optional("preannounce_media_id"): _media_id_validator,
vol.Optional("extra_system_prompt"): str,
}
),
cv.has_at_least_one_key("start_message", "start_media_id"),
),
"async_internal_start_conversation",
[AssistSatelliteEntityFeature.START_CONVERSATION],
)
async def handle_ask_question(call: ServiceCall) -> dict[str, Any]:
"""Handle a Show View service call."""
satellite_entity_id: str = call.data[ATTR_ENTITY_ID]
if call.context.user_id:
user = await hass.auth.async_get_user(call.context.user_id)
if user is None:
raise UnknownUser(
context=call.context,
permission=POLICY_CONTROL,
user_id=call.context.user_id,
)
if not user.permissions.check_entity(satellite_entity_id, POLICY_CONTROL):
raise Unauthorized(
context=call.context,
permission=POLICY_CONTROL,
user_id=call.context.user_id,
perm_category=CAT_ENTITIES,
)
satellite_entity: AssistSatelliteEntity | None = component.get_entity(
satellite_entity_id
)
if satellite_entity is None:
raise HomeAssistantError(
f"Invalid Assist satellite entity id: {satellite_entity_id}"View on GitHub (pinned to 58a3fdb3ea)
Solutions
- Identify which automation/script/user context is making the call (check the error's context.user_id in the log traceback)
- Recreate the user or update the automation to run under a valid user
- Invalidate long-lived tokens belonging to the deleted user via the UI (Security > Long-lived access tokens)
- If writing a custom integration, pass a real Context obtained from hass.auth, not a synthesized user_id
Defensive patterns
Strategy: validation
Validate before calling
user = await hass.auth.async_get_user(context.user_id) if context.user_id else None
if context.user_id and user is None:
# do not issue the service call; the user no longer exists
_LOGGER.warning("Refusing call for deleted user %s", context.user_id) Try / catch
try:
await hass.services.async_call(..., context=context)
except UnknownUser:
# stale user context: refresh tokens / drop stored contexts
raise Prevention
- Never hand-craft Context objects with arbitrary user_id values; obtain contexts from real requests
- Purge stored long-lived tokens when deleting user accounts
- Audit automations after removing users so no orphaned contexts remain
When it happens
Trigger: Calling assist_satellite.ask_question via the WebSocket/API with a context whose user_id belongs to a removed user; a long-lived token whose owner account was deleted; an automation or script replaying a stored context after user deletion.
Common situations: User account deleted while automations still reference it; restored database backup with stale auth tokens; test scripts that hand-craft ServiceCall contexts instead of using hass.services.async_call with a real context.
Related errors
- Unauthorized
- Unauthorized
- Invalid Assist satellite entity id: {satellite_entity_id}
- No answer from satellite
- User is not active
AI-assisted analysis of home-assistant/core@58a3fdb3ea (2026-08-14).
Data as JSON: /api/errors/ccd66f0dbb1e1873.
Report an issue: GitHub.