Upsert fails with a numeric value fields - Python lib bug

check_validations function in \site-packages\pinecone\core\client\ incorrectly mentions “input_values (list/str/int/float/date/datetime): the values that we are checking.”
You can’t check len(input_values) for int values.
ERROR: TypeError: object of type ‘int’ has no len()

Hi @kshrivastava. Can you share the full stack trace for the error you’re seeing? That’ll help us see where in the code the problem is so we can fix it.


Traceback (most recent call last):
File “\”, line 143, in
File “\Python\Python39\lib\site-packages\pinecone\core\utils\”, line 17, in inner_func
return func(*args, **kwargs)
File “\Python\Python39\lib\site-packages\pinecone\”, line 147, in upsert
return self._upsert_batch(vectors, namespace, _check_type, **kwargs)
File “\Python\Python39\lib\site-packages\pinecone\”, line 233, in _upsert_batch
vectors=list(map(_vector_transform, vectors)),
File “\Python\Python39\lib\site-packages\pinecone\”, line 226, in _vector_transform
return Vector(id=id, values=values, metadata=metadata or {}, _check_type=_check_type)
File “\Python\Python39\lib\site-packages\pinecone\core\client\”, line 49, in wrapped_init
return fn(_self, *args, **kwargs)
File “\Python\Python39\lib\site-packages\pinecone\core\client\model\”, line 280, in init = id
File “\Python\Python39\lib\site-packages\pinecone\core\client\”, line 188, in setattr
self[attr] = value
File “\Python\Python39\lib\site-packages\pinecone\core\client\”, line 488, in setitem
self.set_attribute(name, value)
File “\Python\Python39\lib\site-packages\pinecone\core\client\”, line 170, in set_attribute
File “\Python\Python39\lib\site-packages\pinecone\core\client\”, line 908, in check_validations
len(input_values) > current_validations[‘max_length’]):
TypeError: object of type ‘int’ has no len()

Can you post your code? I think I was getting something like that when I first started experimenting with Pinecone (object has no len()) - it may have had to do with the tuple format.

x[‘id’] was numeric…

    for i in tqdm(range(0, len(new_data), batch_size)):
        # find end of batch
        i_end = min(len(new_data), i + batch_size)
        meta_batch = new_data[i:i_end]
        # get ids
        ids_batch = [x['id'] for x in meta_batch]
        # get texts to encode
        texts = [x['text'] for x in meta_batch]
        # create embeddings (try-except added to avoid RateLimitError)
            res = openai.Embedding.create(input=texts, engine=embed_model)
            done = False
            while not done:
                    res = openai.Embedding.create(input=texts, engine=embed_model)
                    done = True
        embeds = [record['embedding'] for record in res['data']]
        # cleanup metadata
        meta_batch = [{
            'text': x['text']
            , 'published': x['published']
        } for x in meta_batch]
        to_upsert = list(zip(ids_batch, embeds, meta_batch))
        # upsert to Pinecone

Hi @Cory_Pinecone - Any insights?


as per documentation, id should be a string :slight_smile:

same in the Python lib documentation:

so if your IDs are an int, convert them to strings with str(id) or any other way :slight_smile:

Hope this helps!

EDIT: Didn’t check the original post facepalm. Will leave the comment either way. Cheers.