Skip to content

[Bug] Upsert fails with object of type 'int' has no len() #163

Closed

Description

@shalimparizaad

Is this a new bug in the Pinecone Python client?

  • I believe this is a new bug in the Pinecone Python Client
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

I am calling upsert with a batch_size of 100. Each batch has tuples of (id, embedding_values, metadata_dict).
This fails with the error:

len(input_values) > current_validations['max_length'])`
TypeError: object of type 'int' has no len()

Expected Behavior

Upsert should work correctly and store my embeddings.

Steps To Reproduce

index.upsert(vectors=[(0, (1.0, 0.2), {'text': 'test text'})])

Relevant log output

Traceback (most recent call last):
  File "my-project/embed.py", line 140, in <module>
    index.upsert(vectors=to_upsert, batch_size=len(meta_batch), show_progress=True)
  File "my-project/venv/lib/python3.10/site-packages/pinecone/core/utils/error_handling.py", line 17, in inner_func
    return func(*args, **kwargs)
  File "my-project/venv/lib/python3.10/site-packages/pinecone/index.py", line 155, in upsert
    batch_result = self._upsert_batch(vectors[i:i + batch_size], namespace, _check_type, **kwargs)
  File "my-project/venv/lib/python3.10/site-packages/pinecone/index.py", line 233, in _upsert_batch
    vectors=list(map(_vector_transform, vectors)),
  File "my-project/venv/lib/python3.10/site-packages/pinecone/index.py", line 226, in _vector_transform
    return Vector(id=id, values=values, metadata=metadata or {}, _check_type=_check_type)
  File "my-project/venv/lib/python3.10/site-packages/pinecone/core/client/model_utils.py", line 49, in wrapped_init
    return fn(_self, *args, **kwargs)
  File "my-project/venv/lib/python3.10/site-packages/pinecone/core/client/model/vector.py", line 280, in __init__
    self.id = id
  File "my-project/venv/lib/python3.10/site-packages/pinecone/core/client/model_utils.py", line 188, in __setattr__
    self[attr] = value
  File "my-project/venv/lib/python3.10/site-packages/pinecone/core/client/model_utils.py", line 488, in __setitem__
    self.set_attribute(name, value)
  File "my-project/venv/lib/python3.10/site-packages/pinecone/core/client/model_utils.py", line 170, in set_attribute
    check_validations(
  File "my-project/venv/lib/python3.10/site-packages/pinecone/core/client/model_utils.py", line 908, in check_validations
    len(input_values) > current_validations['max_length']):
TypeError: object of type 'int' has no len()


### Environment

```markdown
- OS: Mac 13.2.1
- Python: 3.10
- pinecone: 2.2.1

Additional Context

No response

Activity

  1. added
    bug
    on Apr 18, 2023
  2. rajat08 commented on Apr 18, 2023

    @rajat08
    Contributor

    You are passing 0 , an integer, as an id, and it's expecting str. There should be a better error message here.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions