Skip to content

[ENG-19305] fix(media): deliver macro-enabled Office documents in chat - #179

Merged
orswn merged 1 commit into
boonfrom
okka/eng-19305/macro-enabled-media
Sep 2, 2026
Merged

orswn merged 1 commit into
boonfrom
okka/eng-19305/macro-enabled-media

Conversation

@orswn

@orswn orswn commented Sep 2, 2026 •

Copy link
Copy Markdown
Collaborator

Related: ENG-19305

What Problem This Solves

Fixes an issue where users who ask the agent to send back a macro-enabled Office file would receive no attachment and a bare "Media failed." notice in chat, when the file is a .xlsm, .docm, .pptm, or another macro-enabled Office format.

The affected surface is outbound file delivery from an agent turn to any chat channel. Plain .xlsx, .docx, and .pptx files were unaffected and delivered normally, which made the failure look random to the customer. Macro-enabled workbooks are common deliverables in estimating workflows, so the agent could fetch the customer's own file and then fail to hand it back.

Why This Change Was Made

Host-local media sends validate the sniffed content type against an allowlist of document formats. That allowlist covered the non-macro Office family only, so a genuine macro-enabled workbook was classified as an unsupported type and dropped before any upload was attempted.

The allowlist is consulted after the package bytes are already identified, so admitting these formats does not weaken the check: the file still has to prove it is that Office format. Files that merely carry a macro-enabled extension, including opaque binary and plain archives, are still refused.

Extension mappings for the same formats were added to the shared MIME table so outbound filenames keep the correct extension when one has to be derived.

User Impact

Customers can now receive macro-enabled Office files the agent produced or fetched, in the same way non-macro Office files already worked. There is no configuration change and no change for any other file type.

Evidence

Regression tests were added first and failed against the previous behavior:

Tests  3 failed | 74 passed (77)    src/media/web-media.test.ts
Tests  10 failed | 93 passed (103)  packages/media-core/src/mime.test.ts

Failure message before the change:

LocalMediaAccessError: Host-local media sends only allow buffer-verified images,
audio, video, PDF, Office documents, archives, and validated plain-text documents
(got application/vnd.ms-excel.sheet.macroenabled.12).

After the change:

media shard                    19 files, 264 tests passed
unit-fast media-core            6 files, 135 tests passed
agent tool-media suites         2 files,  63 tests passed
oxlint shards                   finished, no findings
tsgo --noEmit                   no output
oxfmt --check                   clean

Negative coverage is included: opaque binary named .xlsm and a plain ZIP named .xlsm both remain rejected with path-not-allowed.


Summary by cubic

Fixes ENG-19305: host-local media sends previously rejected byte-verified macro-enabled Office files and showed “Media failed”; these files now deliver as attachments. Renamed or invalid files remain rejected.

  • Adds MIME detection and filename mappings for .xlsm, .xltm, .docm, .dotm, .pptm, .potm, and .ppsm.
  • Adds regression coverage for valid macro-enabled Office files and disguised binaries.

Written for commit 08ebe32. Summary will update on new commits.

Review in cubic

Sending a macro-enabled workbook fetched by the agent failed with a
generic "Media failed." notice, and no attachment reached the customer.
The host-local media validator allowlisted the non-macro OOXML document
types only, so a byte-verified .xlsm was refused as an unsupported type.

Macro-enabled Office files are ordinary deliverables in estimating
workflows, and the sniffed MIME already proves the package shape before
the allowlist is consulted. Refusing them added no protection while
blocking the customer's requested file.

Allow the seven buffer-verified macro-enabled Office MIME values for
host-local sends and map their extensions in the shared MIME table so
outbound filenames stay correct. The validator keeps rejecting opaque or
generic-archive bytes that merely carry a macro-enabled extension.

Link: https://linear.app/getboon/issue/ENG-19305
@claude

claude Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@orswn

orswn commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator Author

/cr

@claude

claude Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@orswn

orswn commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator Author

Smoke verification

Verified against the exact file from the customer report (6,084,709 bytes, sniffed as application/vnd.ms-excel.sheet.macroenabled.12).

Before and after, same machine, same file. The previous behavior came from a detached worktree at the base branch:

{"build":"pre-fix","file":"real.xlsm","outcome":"BLOCKED","code":"path-not-allowed","message":"Host-local media sends only allow buffer-verified images, audio, video, PDF, Office documents, archives, and validated plain-text documents (got application/vnd.ms-excel.sheet.macroenabled.12)."}
{"build":"fixed","file":"real.xlsm","outcome":"DELIVERED","contentType":"application/vnd.ms-excel.sheet.macroenabled.12","bytes":6084709}

The blocked message is character-for-character the message observed on the affected host during the incident. The delivered buffer length equals the size on disk, so nothing is truncated.

All seven macro-enabled formats load with their matching type:

built.docm -> application/vnd.ms-word.document.macroenabled.12           PASS
built.dotm -> application/vnd.ms-word.template.macroenabled.12           PASS
built.pptm -> application/vnd.ms-powerpoint.presentation.macroenabled.12 PASS
built.potm -> application/vnd.ms-powerpoint.template.macroenabled.12     PASS
built.ppsm -> application/vnd.ms-powerpoint.slideshow.macroenabled.12    PASS
built.xlsm -> application/vnd.ms-excel.sheet.macroenabled.12             PASS
built.xltm -> application/vnd.ms-excel.template.macroenabled.12          PASS

No regression on the common path. Real .xlsx and .docx files still load with their existing types, before and after.

No new spoofing surface. Four disguised files were probed under a macro-enabled extension and under the long-standing non-macro extension, then again on the base build:

{"file":"neg-png.xlsm","outcome":"ACCEPTED","contentType":"image/png"}
{"file":"neg-png.xlsx","outcome":"ACCEPTED","contentType":"image/png"}
{"file":"neg-plain.xlsm","outcome":"ACCEPTED","contentType":"application/vnd.ms-excel.sheet.macroenabled.12"}
{"file":"neg-plain.xlsx","outcome":"ACCEPTED","contentType":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}
{"file":"neg-opaque.xlsm","outcome":"REJECTED","code":"path-not-allowed"}
{"file":"neg-opaque.xlsx","outcome":"REJECTED","code":"path-not-allowed"}
{"file":"neg-empty.xlsm","outcome":"REJECTED","code":"path-not-allowed"}
{"file":"neg-empty.xlsx","outcome":"REJECTED","code":"path-not-allowed"}

Both extensions behave identically, and identically to the base build. Opaque binary and empty files are refused. Two cases are accepted by pre-existing loader behavior that is unrelated to this change and applies equally to non-macro Office extensions:

  • A renamed PNG is delivered as an image, because a sniffed image type short-circuits the document allowlist.
  • A plain ZIP is admitted through the generic-container extension fallback in MIME detection.

Both predate this change and are noted only for completeness.

Not covered: no live host was used, since the affected instance runs a published build. The .docm, .dotm, .pptm, .potm, .ppsm, and .xltm fixtures are synthesized OOXML packages; only the .xlsm, .xlsx, and .docx fixtures are genuine Office output.

Note on the failing review check: the Claude review action cannot exchange an app token on this repository (Workflow validation failed) and CodeQL reports 17 configurations not found. Both are repository configuration issues unrelated to this diff. The cubic reviewer returned neutral because the organization hit its monthly review line limit. All 116 other checks pass.

@orswn

orswn commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator Author

Correction to the smoke evidence above

An independent re-run found one wrong line in my earlier comment. Correcting it here rather than editing the original.

What was wrong. I claimed the base build produced identical output for all eight disguised-file probes. For one fixture, a plain ZIP renamed with a macro-enabled extension, the content type differs:

{"build":"pre-fix","file":"plain-zip.xlsm","outcome":"DELIVERED","contentType":"application/zip"}
{"build":"fixed","file":"plain-zip.xlsm","outcome":"DELIVERED","contentType":"application/vnd.ms-excel.sheet.macroenabled.12"}

Why my first measurement was wrong. The probe imported the base-build loader from a detached worktree whose node_modules was symlinked to the main checkout. The shared MIME package alias therefore resolved to the new extension table, so the base loader ran with part of this change applied. Re-running with the alias resolved inside the worktree gives the numbers above.

Why the conclusion still holds. The accept-or-reject outcome is identical on both builds for every negative fixture:

{"build":"pre-fix","file":"real.xlsm","outcome":"REJECTED","code":"path-not-allowed"}
{"build":"pre-fix","file":"png-renamed.xlsm","outcome":"DELIVERED","contentType":"image/png"}
{"build":"pre-fix","file":"png-renamed.xlsx","outcome":"DELIVERED","contentType":"image/png"}
{"build":"pre-fix","file":"plain-zip.xlsm","outcome":"DELIVERED","contentType":"application/zip"}
{"build":"pre-fix","file":"plain-zip.xlsx","outcome":"DELIVERED","contentType":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}
{"build":"pre-fix","file":"opaque.xlsm","outcome":"REJECTED","code":"path-not-allowed"}
{"build":"pre-fix","file":"opaque.xlsx","outcome":"REJECTED","code":"path-not-allowed"}
{"build":"pre-fix","file":"empty.xlsm","outcome":"REJECTED","code":"path-not-allowed"}
{"build":"pre-fix","file":"empty.xlsx","outcome":"REJECTED","code":"path-not-allowed"}

No fixture flipped from rejected to accepted. The plain ZIP was already deliverable before this change; only its label changed, because the macro-enabled extension now has an entry in the shared extension table and no longer falls back to the sniffed archive type.

Risk Low: a plain ZIP carrying an Office extension is now labelled as an Office document downstream instead of an archive. It does not change what can be sent.

Additional checks from the independent re-run

  • A real macro-enabled workbook renamed to a different macro-enabled extension is delivered with its true content type and keeps the given filename. The base build rejected it. Bytes are trusted and the type is correct, and this mirrors existing behavior for non-macro Office extensions.
  • A macro-enabled package with no extension at all is delivered and gains the correct suffix from the extension table.
  • The size cap still applies to macro-enabled files: Media exceeds 1MB limit (got 5.80MB).
  • Delivered buffers were compared byte for byte against the source, not just by length. Identical on every delivered file.
  • Existing suites re-run independently: 180 tests passed across the two touched test files.

@gandalfboon gandalfboon Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM. Tight, targeted fix. The allowlist expansion is safe because it sits after file-type verifies the package bytes — a .xlsm still has to prove it is a real macro-enabled OOXML package, and the disguised-binary test locks that in. Extension map additions keep outbound filenames correct when derived. Regression tests were authored to fail against prior behavior before the fix, which is the right order. All 90+ checks green, CodeQL neutral (expected). No config change, no impact to other file types. Ship it.

@orswn

orswn commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator Author

/cr

@claude

claude Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@orswn
orswn merged commit 32148d0 into boon Sep 2, 2026
145 of 146 checks passed
@orswn
orswn deleted the okka/eng-19305/macro-enabled-media branch September 2, 2026 13:25
@orswn orswn mentioned this pull request Sep 2, 2026
orswn added a commit that referenced this pull request Sep 2, 2026
Version-bump-only release cutting the three commits merged to boon since
v2026.6.11-boon.32: #177 (ENG-19233), #178, and #179 (ENG-19305).

#179 is customer-blocking: a macro-enabled Office file the agent produced or
downloaded was dropped by the host media allowlist, so the chat showed
"Media failed." while the assistant text claimed the file was attached. The
estimating templates are macro-enabled, so their workbook output always took
the failing path. The fix is on boon but no fleet host can run it until a
tagged release exists.

Bumps the gateway plus @openclaw/slack, @openclaw/msteams, and
@openclaw/diagnostics-prometheus to 2026.6.11-boon.33 in lockstep across all 8
manifests, and adds the CHANGELOG entry. No code changes.

The security-fast failure is unrelated to this release: four HIGH fast-uri
advisories were published upstream about an hour before the run, and the same
audit passes on every earlier PR in this stack. No dependency changed here.
convyusboy added a commit that referenced this pull request Sep 3, 2026
…nflicts)

5 feature/fix commits (boon.32, boon.33): confirm-before-act on ambiguous
requests (#175), unclosed content-block detection at stream finalization
(ENG-19233, #177), >384MB PDF handling (#178), macro-enabled Office document
delivery (#179), cron failure-destination recipient validation (#181).

All conflicts were the established package.json/npm-shrinkwrap.json
version-string pattern (kept 2026.6.34-boon.1), plus a new one this round:
origin/boon still pins fast-uri at 3.1.6 across pnpm-workspace.yaml,
pnpm-lock.yaml, and four npm-shrinkwrap.json files (root, acpx, lobster).
This integration branch already carries a deliberate 4.1.2 override from the
original 2026.6.34 sync (documented in the PR description's "Dependency /
security pins" section: the bump was needed because upstream's 6.34-era code
targets fast-uri's 4.x API, not because it's numerically newer) -- the same
"boon hasn't caught up to a pin this branch already needed" situation as the
`tar` override in that same section. Kept 4.1.2 everywhere.

Verified: pnpm tsgo:core:test + tsgo:extensions:test both clean. Targeted
tests across every touched surface (pdf-tool, web-media, mime, cron
delivery-target-validation + cron.validation, anthropic-transport-stream,
concise-interaction-overlay, embedded-agent-helpers, amazon-bedrock stream
runtime, anthropic prompt-overlay, document-extract) -- 303 passing, 0
failures. One unrelated pre-existing failure noted and left alone:
src/gateway/mcp-http.test.ts's "withdraws a closing runtime before drain
without fencing its successor" fails deterministically in this sandboxed
environment with a raw ECONNRESET on a real loopback TCP socket -- neither
mcp-http.ts nor its test file were touched by this merge, so this is an
environment/network-sandboxing artifact, not a regression from this change.
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