pinecone-io / pinecone-python-client

The Pinecone Python client
https://www.pinecone.io/docs
Apache License 2.0
284 stars 78 forks source link

[Bug] index.list() error message for non-serverless indexes is unclear #331

Open shamussim-ai opened 4 months ago

shamussim-ai commented 4 months ago

Is this a new bug in the Pinecone Python client?

Current Behavior

I followed the code exactly from the documentation

from pinecone import Pinecone

pc = Pinecone(api_key='34zzzzzzzzzz')
index = pc.Index('self-retriever-pae')

# To iterate over all result pages using a generator function
for ids in index.list( namespace="Non_Varicea"):
    print(ids)

This succeeds (as expected) against a serverless index, but when run on a pod-based index (which indeed does not support list()) an unclear error message is returned:

PineconeApiTypeError: Invalid type for variable 'received_data'. Required value type is ListResponse and passed type was str at ['received_data']

Expected Behavior

When run on a non-serverless index (which do not support list()) a clear error message that this is an unsupported operation should be displayed.

Steps To Reproduce

Run code using env specified

Code

from pinecone import Pinecone

pc = Pinecone(api_key='34zzzzzzzzzz')
index = pc.Index('self-retriever-pae')

# To iterate over all result pages using a generator function
for ids in index.list( namespace="Non_Varicea"):
    print(ids)

Relevant log output

PineconeApiTypeError                      Traceback (most recent call last)
[<ipython-input-10-ccee60efe570>](https://localhost:8080/#) in <cell line: 8>()
      6 
      7 # To iterate over all result pages using a generator function
----> 8 for ids in index.list( namespace="Non_Variceal_hi_res"):
      9     print(ids)

10 frames
[/usr/local/lib/python3.10/dist-packages/pinecone/core/client/model_utils.py](https://localhost:8080/#) in attempt_convert_item(input_value, valid_classes, path_to_item, configuration, spec_property_naming, key_type, must_convert, check_type)
   1419         if configuration is None or not configuration.discard_unknown_keys:
   1420             raise get_type_error(input_value, path_to_item, valid_classes,
-> 1421                                  key_type=key_type)
   1422     for valid_class in valid_classes_coercible:
   1423         try:

PineconeApiTypeError: Invalid type for variable 'received_data'. Required value type is ListResponse and passed type was str at ['received_data']

Environment

- OS:Windows
- Python:3.11
- pinecone: 3.0.03

Additional Context

none

volksport commented 4 months ago

Can confirm this is also an issue for us

shamussim-ai commented 4 months ago

Hi there, any updates on this? Thank you

daverigby commented 4 months ago

I attempted to reproduce this on the latest version (v4.0.0) on macOS and don't see the problem anymore.

cbelsole commented 1 month ago

@daverigby I finally figured out why this was not working. This only works for a serverless index. The error message could probably be clearer.

daverigby commented 1 month ago

@daverigby I finally figured out why this was not working. This only works for a serverless index. The error message could probably be clearer.

Thanks @cbelsole . I'll re-open and change to cover the fact that the error is not clear for non-server less indexes.