Skip to content

Cryptic error message when setup_mode of cassandra table is set to incorrect type聽#162

Description

@jordanrfrazier

Summary
I was using the Langchain C* class and noticed that if you accidentally use a string for the setup_mode, you'll get a cryptic error that you may end up debugging for too long 馃檭 . I'm guessing it sneaks into the CQL create statement somehow?

repro

import cassio

from typing import Any, List, Optional, Union, Tuple
from langchain_community.vectorstores import Cassandra
from langchain_community.utilities.cassandra import SetupMode

from langchain_openai import OpenAIEmbeddings

database_id = "..."
token = "..."
table_name = "test"

def build():
    cassio.init(
        database_id=database_id,
        token=token,
    )
    embedding = OpenAIEmbeddings(api_key="...")
    table = Cassandra(
        embedding=embedding,
        table_name=table_name,
        keyspace="default_keyspace",
        setup_mode="Sync" # Accidentally had this as a string instead of SetupMode
        # setup_mode=SetupMode.SYNC, # the correct param
    )
    res = table.search("random query", search_type="similarity")
    print(res)

build()

Run this twice, and you'll see:

cassandra.protocol.SyntaxException: <Error from server: code=2000 [Syntax error in CQL query] message="line 1:107 mismatched input 'None' expecting INTEGER (... TEXT,   vector VECTOR<FLOAT,[None]...)">

Versions
langchain 0.1.19
langchain-community 0.0.38
langchain-core 0.1.52
cassio 0.1.7
Python 3.11.2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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