Skip to content

Unable to add photo to album #207

@nrlulz

Description

@nrlulz

The problem

I was trying to use PhotoAlbum.upload to upload a photo to an album. The call completes without error, the photo is uploaded successfully (I can see it in the root library), something gets added to the album, but it is not visible, and can't be deleted. I did a little digging and found that PhotoAlbum.add_photo is using the photo's id, which comes from the "master record" and looks like AUg8cVR0j7LuL3+Ui3O8TCYeGC/A, where it should be using the record id (asset id? not sure the correct term for it), which comes from the "asset record" and looks like 0F752B8F-083B-4CBC-9C1F-3F43D1515587.

Environment

  • pyiCloud release with the issue (pip show pyicloud): 2.4.1
  • Last working pyiCloud release (if known): N/A
  • Service causing this issue: Photos
  • Python version (python -V): 3.14.3
  • Operating environment (project deps/Docker/Windows/etc.): MacOS

Traceback/Error logs

example of request body captured from pyicloud:

{
  "atomic": true,
  "zoneID": {
    "zoneName": "PrimarySync",
    "ownerRecordName": "...",
    "zoneType": "REGULAR_CUSTOM_ZONE"
  },
  "operations": [
    {
      "operationType": "create",
      "record": {
        "fields": {
          "itemId": {
            "value": "AUg8cVR0j7LuL3+Ui3O8TCYeGC/A"
          },
          "position": {
            "value": 1024
          },
          "containerId": {
            "value": "C4D72ED9-A614-4DEC-B291-0F9D76E21486"
          }
        },
        "recordType": "CPLContainerRelation",
        "recordName": "AUg8cVR0j7LuL3+Ui3O8TCYeGC/A-IN-C4D72ED9-A614-4DEC-B291-0F9D76E21486"
      }
    }
  ]
}

example of request body captured from icloud web:

{
  "atomic": true,
  "zoneID": {
    "zoneName": "PrimarySync",
    "ownerRecordName": "...",
    "zoneType": "REGULAR_CUSTOM_ZONE"
  },
  "operations": [
    {
      "operationType": "create",
      "record": {
        "fields": {
          "itemId": {
            "value": "0F752B8F-083B-4CBC-9C1F-3F43D1515587"
          },
          "position": {
            "value": 1024
          },
          "containerId": {
            "value": "C4D72ED9-A614-4DEC-B291-0F9D76E21486"
          }
        },
        "recordType": "CPLContainerRelation",
        "recordName": "0F752B8F-083B-4CBC-9C1F-3F43D1515587-IN-C4D72ED9-A614-4DEC-B291-0F9D76E21486"
      }
    }
  ]
}

Additional information

I tried making the following change:

diff --git a/pyicloud/services/photos.py b/pyicloud/services/photos.py
index 364c06a..0ccaafb 100644
--- a/pyicloud/services/photos.py
+++ b/pyicloud/services/photos.py
@@ -1590,7 +1590,7 @@ class PhotoAsset:
     @property
     def id(self) -> str:
         """Gets the photo id."""
-        return self._master_record["recordName"]
+        return self._asset_record["recordName"]

     @property
     def filename(self) -> str:

And this makes it send the correct request in this case. But I'm not sure if this is the right change to make. It would be a breaking change for the "get photo by id" call, so it might make sense to handle it separately, or to make it support getting by either id or something.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions