fix: quote replies as ADF instead of round-tripping through text - #72
Merged
Conversation
Contributor
Author
|
/gemini review |
Hinne1
marked this pull request as ready for review
August 6, 2026 08:15
Merging this branch will increase overall coverage
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
atl jira issue comment add --reply-tobuilt its quote by callingapi.ADFToTexton the original comment and re-parsing the result as Markdown.ADFToTextis a display function that deliberately degradesmentionnodes to@Nametext andmedianodes to[Image: alt]text, so every reply to a comment containing an attachment republished a corrupted copy of it.Observed in production: the posted comment's ADF contained 0 media nodes and a literal text node reading
[Image: image-20260805-135958.png]; the author's=>came back as=❭.Fix
Assemble the reply as ADF directly — attribution paragraph, then a
blockquoteholding the original's nodes, then the user's body.blockquoteaccepts exactlyparagraph,bulletList,orderedList,codeBlock,mediaGroup,mediaSingle; those are copied untouched, which is what preserves media and mentions.panelsurvives. Only a subtree with nothing legal in it degrades to text.containsLegalgate stops the recursion descending into inline-content nodes, which would otherwise split a heading's runs into separate paragraphs.ADFContent/ADFMarkcapture their rawattrsJSON and re-emit it unchanged. Without this the reply is rejected outright: real media nodes carry"collection": ""— empty but mandatory — and the typedADFAttrsstruct dropped it viaomitempty, along withlocalIdandwidthType.CommentOptionsgainsBodyADF *ADFfor posting a pre-built document, honoured by bothAddCommentWithOptionsandUpdateComment. No existing caller sets it.Verification
Unit tests cover pass-through of all six legal child types, mention and inline-mark preservation, node-level mark stripping, hoisting out of illegal containers, inline-run integrity, the empty-document case, and attribute round-trip using a media node copied verbatim from a real production comment.
Verified end-to-end against the sandbox by reading the posted comment's raw ADF back from the REST API: the reply posts, the quoted media node keeps
collection: "", and the heading does not fragment. Asserting throughatl comment listwould prove nothing — it renders a live mention and plain text identically, and prints[Image: …]for both a real media node and a dead placeholder, so it passes on the broken code.Side benefit:
issue edit --description --appendalso stops droppingcollection/localIdon fetched media.Known limitations (ticketed, not fixed here)
ADFToTextproduces byte-identical output, and the previous code applied that to the entire comment.Found while building test fixtures, unrelated to this branch: #69, #70.