mem0ai/mem0 · error · HTTPException
API key owner not found.
Error message
API key owner not found.
What it means
Error "API key owner not found." thrown in mem0ai/mem0.
Source
Thrown at server/auth.py:138
user = db.get(User, payload.get("sub"))
if user is None:
raise HTTPException(status_code=401, detail="User not found.")
return user
def _resolve_user_from_api_key(key: str, db: Session) -> User:
prefix = key[:12] if len(key) >= 12 else key
candidates = (
db.execute(select(APIKey).where(APIKey.key_prefix == prefix, APIKey.revoked_at.is_(None))).scalars().all()
)
for candidate in candidates:
if verify_api_key_hash(key, candidate.key_hash):
candidate.last_used_at = datetime.now(timezone.utc)
db.commit()
user = db.get(User, candidate.created_by)
if user is None:
raise HTTPException(status_code=401, detail="API key owner not found.")
return user
raise HTTPException(status_code=401, detail="Invalid API key.")
async def verify_auth(
request: Request,
credentials: HTTPAuthorizationCredentials | None = Depends(bearer_scheme),
x_api_key: str | None = Depends(api_key_header),
) -> User | None:
"""Authenticate via JWT, X-API-Key, or legacy ADMIN_API_KEY. Returns User or None.
A short-lived session is opened only on the branches that query the DB, so no
pooled connection is held for the lifetime of the (possibly long-running) request.
"""
if credentials is not None:
_mark_auth_type(request, "bearer")
with SessionLocal() as db:View on GitHub (pinned to 001c235229)
Solutions
- Verify the API key belongs to an existing user; regenerate the key if the owner was removed.
When it happens
Trigger: Thrown at server/auth.py:138 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/528fc98a12fc582e.
Report an issue: GitHub.