Skip to content

Two fields with the same type are conflicted with KeyError in pydantic #6140

@oytuntez

Description

@oytuntez

Describe the bug
I have a type that looks like this:

class QuoteFileType(BaseDoc):
    """
        QuoteFileType class.
    """
    id: str = None  # same as name, compatibility reasons for a generic, shared `id` field
    name: str = None
    total_count: int = None
    docs: DocList[QuoteFile] = None
    chunks: DocList[QuoteFile] = None

This was working fine until v3.23.3, see PR: #6138

With 3.23.3, we are now getting this error while initializing the gateway:

DEBUG  gateway/rep-0@81761 gRPC call to hnsw for                                
       EndpointDiscovery errored, with error <AioRpcError of                    
       RPC that terminated with:                                                
               status = StatusCode.UNKNOWN                                      
               details = "Unexpected <class 'KeyError'>:                        
       <class 'pydantic.main.ImageDocument'>"                                   
               debug_error_string = "UNKNOWN:Error received                     
       from peer                                                                
       {created_time:"2024-02-16T13:28:39.399741-05:00",                        
       grpc_status:2, grpc_message:"Unexpected <class                           
       \'KeyError\'>: <class                                                    
       \'pydantic.main.ImageDocument\'>"}"                                      
       > and for the 2th time.                         

Describe how you solve it
The issue disappears if I remove one of the DocList[QuoteFile] fields (docs or chunkschunks is there for backward compatibility in one of our use cases).

Environment
jina==3.23.3
docarray==latest upstream with our own fork (i don't think any of our changes are related to this issue)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions