Skip to content

attach_content() may miss existing attachments #1700

Closed

Description

@berke581

Hi, while comparing 4.0.7 and 5.0.5 I noticed a change in how attach_content() checks if a file is already attached. I haven't reproduced it yet, but I'm worried it could cause problems.

In 4.0.7 the file name is sent as a filter, so Confluence returns only the matching attachment (L1594):

attachments = self.get(path=path, headers=headers, params={"filename": name})

In 5.0.5 there is no filter, and the file is searched only in the first batch of results (L1429):

attachments = self.get(path=path, headers=headers)

If a page has many attachments, I think the existing file might not be in that first batch. In that case I'd expect:

  1. The existing file is not found.
  2. attach_content() tries to create it as a new attachment (POST).
  3. Confluence rejects it, because a file with that name already exists.

This seems to have come in with #1666 (5.0.4), which fixed the PUT problem from #1660. The fix itself looks good, only the filename filter from 4.0.7 seems to have been dropped along the way.

Suggestion:

Add params={"filename": name} back to that request, like in 4.0.7.

Environment:

  • atlassian-python-api 5.0.5
  • Confluence Server

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions