Skip to content

[BUG] ZONE_NOT_FOUND (502) when calling get_app_node() with data retuned by get_app_data() #63

@ReagentX

Description

@ReagentX

Describe the bug

This code:

def get_app_data(self):
"""Returns the app library (previously ubiquity)."""
request = self.session.get(
self._service_root + "/retrieveAppLibraries", params=self.params
)
if not request.ok:
self.session.raise_error(request.status_code, request.reason)
return request.json()["items"]
def get_app_node(self, app_id, folder="documents"):
"""Returns the node of the app (ubiquity)"""
return DriveNode(self, self.get_node_data("FOLDER::" + app_id + "::" + folder))

Either generates incorrect drivewsid or does not match the drivewsid expected by Apple.com. This results in a traceback like:

Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
  File "/Users/chris/.pyenv/versions/3.12.2/lib/python3.12/site-packages/icloudpy/services/drive.py", line 81, in get_app_node
    return DriveNode(self, self.get_node_data("FOLDER::" + app_id + "::" + folder))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chris/.pyenv/versions/3.12.2/lib/python3.12/site-packages/icloudpy/services/drive.py", line 35, in get_node_data
    request = self.session.post(
              ^^^^^^^^^^^^^^^^^^
  File "/Users/chris/.pyenv/versions/3.12.2/lib/python3.12/site-packages/requests/sessions.py", line 635, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chris/.pyenv/versions/3.12.2/lib/python3.12/site-packages/icloudpy/base.py", line 158, in request
    self._raise_error(code, reason)
  File "/Users/chris/.pyenv/versions/3.12.2/lib/python3.12/site-packages/icloudpy/base.py", line 187, in _raise_error
    raise api_error
icloudpy.exceptions.ICloudPyAPIResponseException: ZONE_NOT_FOUND (502)

To Reproduce
Code to reproduce the behavior:

for item in api.drive.get_app_data():
    try:
        print(item['zone'])
        print(api.drive.get_app_node(item['zone']))
    except:
        print("Invalid data from api!")

Expected behavior

Output shows the app node data for all apps:

iCloud.com.apple.iBooks
{type: app_library, name: Books}
F3LWYJ7GM7.com.apple.musicmemos.ideas
{type: app_library, name: Music Memos}

Actual behavior

Output catches incorrect/invalid drivewsids:

com.apple.videoapps.cloudcontent.imovieios.private
Invalid data from api!
iCloud.com.mattermost.rn
Invalid data from api!
com.apple.notes
Invalid data from api!
PB4R74AA4J.com.junecloud.Deliveries
{type: app_library, name: Deliveries}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions