Skip to content

Qdrant get_collections IndexError: tuple index out of range #491

@rayenebech

Description

@rayenebech

Hi! I am using langtrace with Crewai and Qdrant database. I have this function that lists existing Qdrant collections:

def get_qdrant_collections():
    from qdrant_client import QdrantClient
    try:
        client = QdrantClient(url=os.getenv("QDRANT_HOST", "http://qdrant:6333"))
        logger.debug("Connected to Qdrant server")
        result = client.get_collections()
        logger.debug(f"Raw Qdrant response: {result}")
        
        # Check if result exists and has the expected structure
        if result is None:
            logger.error("Qdrant returned None response")
            return []
        
        # Get collections list safely
        collections = getattr(result, 'collections', []) or []
        logger.debug(f"Found collections: {collections}")
        
        # Extract names safely
        collections_names = []
        for collection in collections:
            if hasattr(collection, 'name'):
                collections_names.append(collection.name)
                
        logger.info(f"Retrieved collection names: {collections_names}")
        return collections_names
        
    except Exception as e:
        logger.error(f"Error in listing collections: {str(e)}", exc_info=True)
        return []

The function works well when run separately. However if it is run inside the CrewAI flow and therefore tracked by langtrace I get the following error:

backend_server | result = client.get_collections()
backend_server | File "/usr/local/lib/python3.10/site-packages/langtrace_python_sdk/instrumentation/qdrant/patch.py", line 66, in traced_method
backend_server | collection_name = kwargs.get("collection_name") or args[0]
backend_server | IndexError: tuple index out of range
backend_server | ERROR:helpers:Error in listing collections: tuple index out of range

I am using [email protected]
Python 3.10.16

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions