Skip to content

✨Fix work package comment attachment parsing #19925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

Eric-Guo
Copy link
Contributor

@Eric-Guo Eric-Guo commented Aug 14, 2025

Notice this PR is mostly done by cursor GPT 5 high. original PR

What are you trying to accomplish?

Enable users to post comments on work packages that include tags referencing existing attachments without encountering a "attachments cannot be changed" error.

Screenshots

After fix it can including the attachment image.

企业微信截图_8e25d35e-4437-4423-9b85-ad30ca665d66

What approach did you choose and why?

The CommentAttachmentsClaims::SetAttributesService was attempting to claim (assign) attachments referenced in a work package comment. This led to a PropertyConstraintViolation ("附件不能更改") when the referenced attachment was already associated with the work package.

The chosen approach modifies the SetAttributesService to:

Extract all attachment IDs from the comment's HTML.
Filter these IDs to include only attachments that are currently unassigned (i.e., not yet linked to any container).
Pass only these truly "claimable" attachment IDs to the underlying service.
This ensures that existing attachments already linked to the work package are ignored by the claiming process, preventing the validation error, while still allowing the comment to be saved and the image to be displayed from its existing URL.

Merge checklist

  • Added/updated tests
  • Tested major browsers (Chrome, Firefox, Edge, ...)

cursoragent and others added 2 commits August 14, 2025 20:53
@Eric-Guo Eric-Guo changed the title Fix work package comment attachment parsing ✨Fix work package comment attachment parsing Aug 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants