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:
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)