fix(buzz-cli): deliver documents as file cards instead of broken images - #7479
Open
kaminai0000 wants to merge 1 commit into
Open
fix(buzz-cli): deliver documents as file cards instead of broken images#7479kaminai0000 wants to merge 1 commit into
kaminai0000 wants to merge 1 commit into
Conversation
`buzz messages send --file` and `buzz upload file` were both stricter and less correct than the relay they talk to, so an agent could not attach any non-image artifact to a conversation. Two defects, both invisible to the sender: 1. `ALLOWED_MIMES` listed only 4 image types plus `video/mp4`, rejecting uploads client-side with `unsupported file type: …` before the request reached the relay. The relay's `/upload` route already sniffs documents, archives, text and data onto its generic-file path (`buzz-media::validation`, a deny-list that blocks only active content and executables) and serves them as downloads. Desktop users could attach a PDF; agents could not. 2. Once past that gate, the markdown embed was built from a two-way branch — `video/*` got `` and *everything else* got ``. A document was therefore announced to the client as an image and rendered as a permanently broken image placeholder. The send still returned `accepted: true`, so the failure only ever surfaced in the recipient's client. Generic files now use the same plain `[filename](url)` form Buzz Desktop emits (`imetaMediaMarkdown.ts`), which the renderer recognises as a non-media blob and upgrades to a download card, and the `imeta` tag carries `filename` so the card has a label instead of the blob hash. Markdown metacharacters in the label are escaped so a name like `a].pdf` cannot break the link. The embed choice is extracted into `format_media_markdown` so the branch is covered directly rather than through the async send path; reverting either fix fails the new tests. Fixes block#3083 Fixes block#7324 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: kaminai0000 <kaminai0000@gmail.com>
🔐 Codex Security Review
|
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.
Summary
buzz-cliis both stricter and less correct than the relay it talks to whenattaching a non-image file, so an agent cannot deliver any document to a
conversation. Two defects, neither visible to the sender.
Fixes #3083
Fixes #7324
1. Uploads were rejected client-side (#3083)
ALLOWED_MIMESlisted only four image types plusvideo/mp4, so anything elsefailed with
unsupported file type: …before the request reached the relay.The relay's
/uploadroute already sniffs documents, archives, text and dataonto its generic-file path (
buzz-media::validation, a deny-list that blocksonly active content and executables) and serves them with
Content-Disposition: attachment. Desktop users could attach a PDF; agentscould not.
2. Everything non-video was announced as an image (#7324)
The markdown embed came from a two-way branch:
video/*gotandeverything else got
. A document was therefore announced to theclient as an image and rendered as a permanently broken image placeholder —
while the send returned
accepted: true, so the failure only ever appeared inthe recipient's client.
Generic files now use the same plain
[filename](url)form Buzz Desktop emits(
imetaMediaMarkdown.ts::formatImetaMediaLine), which the renderer recognisesas a non-media blob and upgrades to a download card. The
imetatag carriesfilenameso the card has a label instead of the blob hash, and markdownmetacharacters in the label are escaped so a name like
a].pdfcannot breakthe link.
Testing
The embed choice is extracted into
format_media_markdownso tests bind theproduction branch rather than a copy of it. Reverting either fix turns the new
tests red — verified by re-introducing the
catch-all, which failsthree of them.
cargo test -p buzz-cli --lib— 469 passedcargo fmt --check -p buzz-cli,cargo clippy -p buzz-cli --all-targets— cleanReproduced end to end against a self-hosted relay: a headless
buzz-acpagentgenerating an
.xlsxcould not attach it at all before this change, anddelivers it as a working download card after.
🤖 Generated with Claude Code