Merge pull request #185 from hanushh/fix-agent-auth-optional-401

fix(backend): Return None instead of 401 when agent not found in get_agent_auth_context_optional
This commit is contained in:
Abhimanyu Saharan
2026-02-27 23:36:40 +05:30
committed by GitHub

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:
if agent_token:
logger.warning( logger.warning(
"agent auth optional invalid token path=%s token_prefix=%s", "agent auth optional invalid token path=%s token_prefix=%s",
request.url.path, request.url.path,
resolved[:6], 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)