✨Fix work package comment attachment parsing #19925
Open
+86
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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