Skip to content

Fix spurious mentions from literal action-text-attachment tags in CLI content#57

Merged
robzolkos merged 5 commits intomasterfrom
fix-markdown-attachment-sanitization
Mar 2, 2026
Merged

Fix spurious mentions from literal action-text-attachment tags in CLI content#57
robzolkos merged 5 commits intomasterfrom
fix-markdown-attachment-sanitization

Conversation

@robzolkos
Copy link
Copy Markdown
Collaborator

Summary

  • An LLM using the CLI created a card with markdown content that included a backtick-wrapped <action-text-attachment> tag (as documentation about how attachments work). Since the CLI sent content as-is, Action Text parsed the literal tag as a real attachment, creating spurious mentions and causing Mention::CreateJob errors.
  • The fix runs card descriptions and comment bodies through goldmark (markdown-to-HTML) before sending, converting backtick-wrapped HTML tags into escaped <code> blocks while passing through raw HTML unchanged so real attachments continue to work.
  • Also fixes parseAttachments to handle <figure> blocks that appear outside the </action-text-attachment> closing tag (caused by goldmark wrapping bare attachment tags in <p>), which was a pre-existing test failure.
  • Plain text content without any HTML or markdown syntax passes through unchanged.

Changes

  • internal/commands/markdown.go — New markdownToHTML() function with goldmark conversion and post-processing for backtick-wrapped attachment tags in HTML blocks
  • internal/commands/card.go — Card create/update descriptions run through markdownToHTML()
  • internal/commands/comment.go — Comment create/update bodies run through markdownToHTML()
  • internal/commands/attachment.go — Updated parseAttachments regex to capture trailing <figure> blocks
  • internal/commands/markdown_test.go — 8 unit tests covering all conversion scenarios
  • internal/commands/attachment_test.go — Unit test for figure-outside-attachment parsing
  • e2e/tests/markdown_sanitization_test.go — 5 e2e tests: backtick escaping (card + comment), real attachments still work (card + comment), and mixed real + backtick in same description

…xt attachments

An LLM using the CLI created a card with markdown content that included
a backtick-wrapped `<action-text-attachment>` tag. Since the CLI sent
content as-is, Action Text parsed the literal tag as a real attachment,
triggering Mention::CreateJob and causing errors.

The fix runs all card descriptions and comment bodies through goldmark
(markdown-to-HTML) before sending. This converts backtick-wrapped HTML
tags into escaped `<code>` blocks while passing through raw HTML
unchanged, so real attachments continue to work.

Also fixes parseAttachments to handle <figure> blocks that appear after
the closing </action-text-attachment> tag (caused by goldmark wrapping
bare attachment tags in <p>).
Goldmark doesn't convert backtick code spans inside HTML blocks, so
backtick-wrapped <action-text-attachment> tags in mixed HTML/markdown
pass through as raw HTML. Add a post-processing step to escape any
attachment tags that remain wrapped in literal backticks.

Also adds an e2e test for the combined case: a real attachment alongside
backtick-wrapped example attachment tags in the same description.
- TestMarkdownToHTML: 7 tests covering backtick escaping, raw HTML
  passthrough, mixed content, and real alongside backtick attachments
- TestParseAttachments: add case for figure block outside attachment
  tags (p-wrapped HTML from markdown conversion)
- Update TestCommentCreate to expect markdown-converted body
Plain text without HTML tags or markdown syntax (backticks, angle
brackets) should pass through unchanged to avoid wrapping simple
text in unnecessary <p> tags.

Adds unit test verifying plain text passthrough and reverts the
comment test expectation back to plain text.
@robzolkos robzolkos force-pushed the fix-markdown-attachment-sanitization branch from c05232e to 9c89d4b Compare March 2, 2026 16:16
@robzolkos robzolkos merged commit a822e05 into master Mar 2, 2026
1 check passed
@robzolkos robzolkos deleted the fix-markdown-attachment-sanitization branch March 2, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant