fix: get_peer_card should not create peer/workspace

This commit is contained in:
Benjamin McCormick 2026-02-06 15:55:58 -05:00
parent 79a4a297ea
commit a78dfc24af
1 changed files with 7 additions and 4 deletions

View File

@ -3,7 +3,7 @@ from __future__ import annotations
import logging
from typing import cast
from sqlalchemy import update
from sqlalchemy import select, update
from sqlalchemy.ext.asyncio import AsyncSession
from src import models, schemas
@ -34,10 +34,13 @@ async def get_peer_card(
Returns:
The peer's card text if present, otherwise None (also None if peer not found).
"""
result = await get_or_create_peers(
db, workspace_name, [schemas.PeerCreate(name=observer)]
peer = await db.scalar(
select(models.Peer)
.where(models.Peer.workspace_name == workspace_name)
.where(models.Peer.name == observer)
)
peer = result.resource[0]
if peer is None:
return None
return cast(
list[str] | None,
peer.internal_metadata.get(