[REST API] Update Attachment Property Fails | Property with key [XXXXXXX] on attachment with id [XXXXXX] already exists

XMLWordPrintable

    • 2
    • Minor
    • 0

      Issue Summary

      The problem arises when the app creates/updates an attachment property, which is stored as a new custom entry inside the content table. This entry includes information about the current spaceId where the property was created.

      However, if the attachment property is modified while it is still in spaceId A and later the attachment is moved to spaceId B, the latest property entry still points to spaceId A. This inconsistency occurs because the spaceId is not updated when the property is moved to a new space.

      Later If spaceId A is sent to the trash, the Attachment Properties API cannot retrieve the property data since it is still linked to the trashed space, causing failures in data recovery.

      Steps to Reproduce

      1. Create a new page on the SPACE A and upload an attachment to it
      2. Create a new attachment property using the API
      3. Move the Page to the SPACE B
      4. Try to get all the properties referenced to the attachment in the page using GET https://xxxxxx.atlassian.net/wiki/api/v2/attachments/XXXXXXX/properties
      5. Send the SPACE A to trash
      6. Try to get all the properties referenced to the attachment in the page using GET https://xxxxxx.atlassian.net/wiki/api/v2/attachments/XXXXXXX/properties
      7. As the last step fails apps might asume the property does not exist and then tries to create a new property but as the key already exist on the database then it fails which is expected
      POST: https://xxxxxx.atlassian.net/wiki/api/v2/attachments/XXXXXXX/properties
      {
      "errors": [
      {
      "status": 409,
      "code": "CONFLICT",
      "title": "Property with key [XXXXXXX] on attachment with id [XXXXXX] already exists",
      "detail": null
      }
      ]
      } 

      The behaviour described on the step 6 should not occur

      Expected Results

      Once a page is moved from one space to the other the attachments and its linked data should be moved as well

      Actual Results

      The API request GET https://xxxxxx.atlassian.net/wiki/api/v2/attachments/XXXXXXX/properties do not get any response and the properties still linked to the SPACE A and is in TRASHED state

      Workaround

      Update the property instead creating a new one, however database access might be required to get the correct property id and the last version

              Assignee:
              Unassigned
              Reporter:
              Michael Gonzalez (Inactive)
              Votes:
              3 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated: