box / box-python-sdk

Box SDK for Python
http://opensource.box.com/box-python-sdk/
Apache License 2.0
417 stars 214 forks source link

I got some errors... #823

Closed c-rei closed 12 months ago

c-rei commented 1 year ago

I got some error with status=200, my code just like these...

a). collaborations = some_item.get_collaborations(), got an error like this... BoxAPIException(status=200, code=None, message='Non-json response received, while expecting json response.', request_id=None, headers={'Date': 'Mon, 03 Jul 2023 01:16:19 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'x-envoy-upstream-service-time': '36119', 'strict-transport-security': 'max-age=31536000', 'box-request-id': '0dec014753f2041931771864d911c0109', 'cache-control': 'no-cache, no-store', 'Via': '1.1 google', 'Alt-Svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000'}, url='https://api.box.com/2.0/files/870778406860/collaborations', method='GET', context_info=None)

b). items = some_folder.get(), got an error like this... BoxAPIException(status=200, code=None, message='Non-json response received, while expecting json response.', request_id=None, headers={'Date': 'Mon, 03 Jul 2023 01:28:14 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'x-envoy-upstream-service-time': '10475', 'etag': '"0"', 'box-request-id': '045295be86c0ccb4b4a9e54d9c02880a3', 'cache-control': 'no-cache, no-store', 'strict-transport-security': 'max-age=31536000', 'Via': '1.1 google', 'Alt-Svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000'}, url='https://api.box.com/2.0/folders/147613739634', method='GET', context_info=None)

While I want to extract the collaborations under a folder that contains 12,000 items, I got error a) or error b).

Please give me any advises. Thanks.

Versions Used

Python SDK: 3.6.1 Python: 3.8.10

mwwoda commented 1 year ago

Hi @c-rei Could you give us a minimal, reproducible example of your problem? Preferably as a code sample and steps on how to configure the application on the box side (especially folders and collaborators).
Is it always happening for the same folders? What type of auth are you using? Is it authorized by the enterprise?

This may also be related, so you can look at https://github.com/box/box-python-sdk/issues/741 and check if you have invited collaborators to the folders correctly.

c-rei commented 1 year ago

Thanks for your response, my customer wants to extract the metadata information of the contents under some folder. So I make a recursive routine to do that. I'll try to give you a minimal sample.

Yes it is always happening for the especially folder that contains 12,000 items, I used Traditional 3-legged OAuth2, it is authorized by the enterprise.

samples:

def route_extract(root_folder): ----items = root_folder.get_items() ----for item in items: --------item = item.get() --------item_collabors = {} --------item_owner = item.owned_by --------collaborations = item.get_collaborations() --------for collab in collaborations: ------------target = collab.accessible_by ------------if target is None: ----------------a_key = collab.invite_email ----------------item_collabors[a_key] = ({"name": "pending", "type": "user"}, collab.role) ------------else: ----------------a_key = target.name if target.type == 'group' else target.login ----------------item_collabors[a_key] = ({"name": target.name, "type": target.type}, collab.role) ------------me_rights = None if self.me.login not in item_collabors else item_collabors[self.me.login][1] ------------if process_code['owner_only'] == "on" and self.me != item_owner and me_rights != 'co-owner': ----------------continue ------------metadata = item.metadata(scope='enterprise', template=process_code['meta']['templateKey']) ------------meta = metadata.get() ------------>>>just save meta to excel file... --------if item.type == 'folder': ------------route_extract(item)

mwwoda commented 1 year ago

I still have not been able to reproduce this on my side. My guess is that your setup must be somewhat specific to trigger such a response from the SDK. Could you elaborate a bit more on your folder structure and how permissions are setup? Was this folder created using this app or through the user interface? Are you acting as a service account when using SDK? Does the account you are acting as have permission to access this folder? If not, you can try adding that account as a collaborator via the API.

c-rei commented 1 year ago

Thanks for your support. I had heard my customer for the folder structure, so result is, The folder was created by the user interface and the account which executed my program has an editor permission for this folder. Box shield was set for this folder. But I let them to try some subfolder under the same folder, it is successful. So I think that this problem occurs when there are many contents under the folder.

congminh1254 commented 1 year ago

Hi @c-rei I'm sorry for getting back to you so late.

Can you verify if the issue still there? If it still not working, we can do a quick call to further investigate your case.

I'm waiting for your answer.

Bests, Minh

c-rei commented 1 year ago

Thanks for your responses.

It still not working from my customer's feedback. I hope any investigate.

Thanks.

congminh1254 commented 1 year ago

Hi @c-rei

We tried with the folder with over 12000 items, with your code above, and everything still working well.

Can you check if the issue always happen to on the same file / folder or it will be change for every time?

I need these information to further investigate this issue.

Thank you.

c-rei commented 1 year ago

Hi, Thank you for your help.

Did you set Box shield on the folder with over 12000 items. I think Box shield will take a long time to check any access.

Thanks.

c-rei commented 1 year ago

Hi, I got the new error from our customer, same as before. And not same contents.

2023-07-10 09:57:57,031: boxreport: 280: run():ERROR:BoxAPIException(status=200, code=None, message='Non-json response received, while expecting json response.', request_id=None, headers={'Date': 'Mon, 10 Jul 2023 00:57:55 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'x-envoy-upstream-service-time': '30359', 'strict-transport-security': 'max-age=31536000', 'box-request-id': '0fa02e7e87096c9ea58aca7d22d58a5bb', 'cache-control': 'no-cache, no-store', 'Via': '1.1 google', 'Alt-Svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000'}, url='https://api.box.com/2.0/files/1231720344934/collaborations', method='GET', context_info=None) error occurred. 2023-07-10 10:31:40,906: boxreport: 280: run():ERROR:BoxAPIException(status=200, code=None, message='Non-json response received, while expecting json response.', request_id=None, headers={'Date': 'Mon, 10 Jul 2023 01:31:40 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'x-envoy-upstream-service-time': '30383', 'strict-transport-security': 'max-age=31536000', 'box-request-id': '0f464a0fff8cd581c26d9101953387bff', 'cache-control': 'no-cache, no-store', 'Via': '1.1 google', 'Alt-Svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000'}, url='https://api.box.com/2.0/files/1221625690581/collaborations', method='GET', context_info=None) error occurred.

And has some new error, like this.

2023-07-24 10:56:40,445: boxreport: 280: run():ERROR:ProxyError(MaxRetryError("HTTPSConnectionPool(host='api.box.com', port=443): Max retries exceeded with url: /2.0/files/1071311568791/collaborations (Caused by ProxyError('Cannot connect to proxy.', ConnectionAbortedError(10053, '確立された接続がホスト コンピューターのソウトウェアによって中止されました。', None, 10053, None)))")) error occurred.

c-rei commented 1 year ago

'確立された接続がホスト コンピューターのソウトウェアによって中止されました。' ↓↓↓↓↓↓↓ An established connection was aborted by the software in your host machine

congminh1254 commented 1 year ago

Hi @c-rei We have just released version 3.8.1 of BoxSDK, hope it can fix your issue. Please bump the version and let us know if it help. Thankyou.

c-rei commented 1 year ago

Hi, thanks your responses. I will update my BoxSDK version, and let you know the result.

Thanks.

congminh1254 commented 12 months ago

Hi @c-rei

I will close this issue for now, if you still need help, just let us know.

Best regards, Minh