Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DB error: Could not find field at updateOneLibraryAgent.data.Agent.connect #9250

Closed
Pwuts opened this issue Jan 13, 2025 — with Linear · 1 comment
Closed

Fix DB error: Could not find field at updateOneLibraryAgent.data.Agent.connect #9250

Pwuts opened this issue Jan 13, 2025 — with Linear · 1 comment
Assignees
Labels
bug Something isn't working

Comments

Copy link
Member

Pwuts commented Jan 13, 2025

Database error updating agent version in library: Could not find field at updateOneLibraryAgent.data.Agent.connect

Seems to be introduced by #9211.

Culprit:

async def update_agent_version_in_library(
     user_id: str, agent_id: str, agent_version: int
 ) -> None:
     """
     Updates the agent version in the library
     """
     try:
         await prisma.models.LibraryAgent.prisma().update(
             where={
                 "userId": user_id,
                 "agentId": agent_id,
                 "useGraphIsActiveVersion": True,
             },
             data=prisma.types.LibraryAgentUpdateInput(
                 Agent=prisma.types.AgentGraphUpdateOneWithoutRelationsInput(
                     connect=prisma.types.AgentGraphWhereUniqueInput(
                         id=agent_id,
                         version=agent_version,
                     ),
                 ),
             ),
         )
     except prisma.errors.PrismaError as e:
         logger.error(f"Database error updating agent version in library: {str(e)}")



         raise backend.server.v2.store.exceptions.DatabaseError(
             "Failed to update agent version in library"
         ) from e
@Pwuts Pwuts added the bug Something isn't working label Jan 13, 2025 — with Linear
@Pwuts Pwuts self-assigned this Jan 13, 2025
Copy link
Member Author

Pwuts commented Jan 13, 2025

Analysis shows that prisma.types.AgentGraphWhereUniqueInput is being used incorrectly, which somehow isn't flagged by the type checker:

_AgentGraphCompoundPrimaryKeyInner = TypedDict(
    '_AgentGraphCompoundPrimaryKeyInner',
    {
        'id': '_str',
        'version': '_int',
    },
    total=True
)

_AgentGraphCompoundPrimaryKey = TypedDict(
    '_AgentGraphCompoundPrimaryKey',
    {
        'graphVersionId': '_AgentGraphCompoundPrimaryKeyInner',
    },
    total=True
)

AgentGraphWhereUniqueInput = _AgentGraphCompoundPrimaryKey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant