fix(backend): Return None instead of 401 when agent not found in get_agent_auth_context_optional

This commit is contained in:
Hanush H Nair
2026-02-27 23:19:40 +05:30
parent 09643b8cf7
commit 4c35cb03ad

View File

@@ -168,11 +168,12 @@ async def get_agent_auth_context_optional(
return None return None
agent = await _find_agent_for_token(session, resolved) agent = await _find_agent_for_token(session, resolved)
if agent is None: if agent is None:
logger.warning( if agent_token:
"agent auth optional invalid token path=%s token_prefix=%s", logger.warning(
request.url.path, "agent auth optional invalid token path=%s token_prefix=%s",
resolved[:6], request.url.path,
) resolved[:6],
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED) )
return None
await _touch_agent_presence(request, session, agent) await _touch_agent_presence(request, session, agent)
return AgentAuthContext(actor_type="agent", agent=agent) return AgentAuthContext(actor_type="agent", agent=agent)