Skip to content

List the files inside an embedded text/html attachment - #346

Open
adammiribyan wants to merge 1 commit into
basecamp:mainfrom
adammiribyan:list-files-inside-embedded-html-attachments
Open

List the files inside an embedded text/html attachment#346
adammiribyan wants to merge 1 commit into
basecamp:mainfrom
adammiribyan:list-files-inside-embedded-html-attachments

Conversation

@adammiribyan

@adammiribyan adammiribyan commented Aug 27, 2026

Copy link
Copy Markdown

hey attachment list returns 0 attachments for an inbound HTML email (Outlook and the like) even when hey thread read shows the 📎 lines, so hey attachment save has no ID to work with.

Why: since 21751f9 such an email is one text/html trix <figure> whose content string holds the original markup. findAttachments stops at that figure; the <action-text-attachment> file elements are inside the markup.

Fix: findAttachments recurses into the embedded markup the same way findImages already does, with the same embeddedContentDepthLimit. The wrapper itself is still not listed (TestExtractAttachmentsSkipsEmbeddedHTMLAttachment is unchanged).

Review: one switch in findAttachments mirroring the one in findImages, plus two tests — the first fails on main, the second pins the depth limit. make check passes.

An HTML email from outside HEY arrives as one <figure data-trix-attachment>
with contentType "text/html" and the original markup in its content string
(21751f9). When that email carried files -- an Outlook sender attaching two
PDFs, say -- they sit inside that markup as <action-text-attachment>
elements, so `hey attachment list` answered "0 attachments" for a thread
whose `hey thread read` plainly showed the 📎 lines, and `hey attachment
save` had nothing to address.

findAttachments now walks into the embedded markup the way findImages
already does, bounded by embeddedContentDepthLimit, and lists what it finds
there. The wrapper itself is still not listed: an embedded body is not a
downloadable file, and the test that says so still holds.
@adammiribyan
adammiribyan requested a review from a team as a code owner August 27, 2026 09:34
Copilot AI balanced review requested due to automatic review settings August 27, 2026 09:34
@github-actions github-actions Bot added the tests label Aug 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enables attachment discovery within embedded HTML email bodies while preserving wrapper exclusion and bounded recursion.

Changes:

  • Recursively extracts nested downloadable attachments.
  • Adds extraction and recursion-limit tests.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/htmlutil/htmlutil.go Traverses embedded HTML when extracting attachments.
internal/htmlutil/htmlutil_test.go Tests nested extraction and depth limiting.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants