Skip to content

fix(msteams): surface the Bot Framework/Graph HTTP body on send failures ENG-16131 - #54

Merged
monac24 merged 1 commit into
boonfrom
fix/msteams-surface-graph-400-body
Jul 16, 2026
Merged

monac24 merged 1 commit into
boonfrom
fix/msteams-surface-graph-400-body

Conversation

@monac24

@monac24 monac24 commented Jul 16, 2026 •

Copy link
Copy Markdown

Problem

On the live arguijo host, every Teams upload-file action fails with:

[tools] message failed: msteams file send failed (HTTP 400): Request failed with status code 400 raw_params={"action":"upload-file",...}

Text replies to the same thread succeed — only file upload fails — so auth/connectivity is fine and the 400 is specific to how the send request is built. But the actual Bot Framework / Microsoft Graph rejection reason is invisible: the log only shows the opaque Request failed with status code 400, so we can't tell which field Graph rejected.

Root cause of the missing detail

The outbound send/upload catch blocks format the error with formatUnknownError(err), which for an Error just returns err.message. The Teams SDK Bot Connector client is axios-based, and axios puts the parsed response body on err.response.data — which was never read. (extractErrorCode only looked at err.response.body, the Graph-SDK shape.) So the real { error: { code, message } } was discarded on every send failure.

Change (diagnostic-only — no send behavior changes)

  • extractErrorCode now checks both response.data (axios / Bot Connector) and response.body (Graph SDK), so error-code classification works regardless of which client threw.
  • New exported formatMSTeamsErrorDetail(err) appends the response body's code: message (or a stringified body) to the base message, de-duplicating when the detail is already contained in the base.
  • All five send-path catch blocks — send / file-send / proactive / edit / delete — now use formatMSTeamsErrorDetail in place of formatUnknownError.

After this, the next live failure will log the concrete Graph/Connector reason (e.g. an unsupported-attachment-in-channel message), which is needed to land the actual functional fix for the channel upload-file 400.

Scope note

This is deliberately Part A only (error surfacing). A suspected functional fix — gating the native file.info card to group chats and delivering a SharePoint share-link in channels — is intentionally not included, because that root cause can't be confirmed until this PR makes the real Graph error body visible. Follow-up will be a separate PR once a live failure prints the exact rejected field.

Testing

  • extensions/msteams/src/errors.test.ts — new cases: error-code extraction from an axios response.data body; formatMSTeamsErrorDetail appends the body, falls back to the base message, de-duplicates, and stringifies a non-standard body.
  • vitest run msteams errors + send suites: 35 passed.
  • pnpm tsgo:extensions and pnpm tsgo:extensions:test: clean (exit 0).
  • oxlint on changed files: clean.

Refs ENG-14349 / ENG-14431 (arguijo Teams attachment delivery).

🤖 Generated with Claude Code


Summary by cubic

Surface Bot Framework/Microsoft Graph error bodies on MS Teams send failures so logs show the real rejection reason instead of just “Request failed with status code 400”. No behavior changes; this unblocks diagnosing upload-file 400s on arguijo (ENG-14349, ENG-14431).

  • Bug Fixes
    • extractErrorCode now reads response.data (axios/Bot Connector) as well as response.body (Graph SDK).
    • Added formatMSTeamsErrorDetail(err) to append {error.code}: message (or stringified body) to the base message, with de-duplication.
    • Replaced formatUnknownError with the new formatter across send paths (send, file upload, proactive, edit, delete).

Written for commit ecc6c60. Summary will update on new commits.

Review in cubic

Outbound send/upload errors were formatted with `formatUnknownError(err)`,
which for an axios-shaped error (the Teams SDK Bot Connector client) returns
only the opaque default message "Request failed with status code 400". The
actual rejection reason from Bot Framework / Microsoft Graph lives on
`err.response.data` and was discarded, so operators saw an HTTP 400 with no
indication of *why* a file/message send was rejected.

- `extractErrorCode` now checks `response.data` in addition to `response.body`,
  so error-code classification works for both the axios (Bot Connector) and
  Graph SDK error shapes.
- New `formatMSTeamsErrorDetail(err)` appends the response body's
  `{ error: { code, message } }` (or a stringified body) to the base message,
  de-duplicating when the detail is already present.
- All five send-path catch blocks (send/file-send/proactive/edit/delete) now
  use it in place of `formatUnknownError`.

This is diagnostic-only: no send behavior changes. It unblocks root-causing the
arguijo Teams `upload-file` HTTP 400 failures, whose true Graph reason is
currently invisible in the gateway log.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@claude

claude Bot commented Jul 16, 2026

Copy link
Copy Markdown

Claude Code is working…

I'll analyze this and get back to you.

View job run

@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.

Approved. Tight, well-scoped diagnostic PR.

  • Scope is right: Part A (error surfacing) only, with the functional fix correctly deferred until a live failure prints the real Graph body — sound reasoning, no premature guessing.
  • extractResponseBodyDetail mirrors the both-body-shape loop (response.body Graph SDK + response.data axios/Bot Connector) already used in extractErrorCode; consistent, no duplicated concern, and the de-dup guard avoids doubling the base message.
  • All five catch blocks (send/file-send/proactive/edit/delete) swapped uniformly — additive, no behavior change.
  • Tests cover the cases that matter: axios body code extraction, append, no-body fallback, de-dup, non-standard body stringify. 35 passing + tsgo/oxlint clean.
  • No secrets, no new authz/injection surface; the stringified detail is Graph rejection reasons, not payload/PII.

Ship it.

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 3 files

Re-trigger cubic

@claude

claude Bot commented Jul 16, 2026

Copy link
Copy Markdown

Claude Code is working…

I'll analyze this and get back to you.

View job run

@monac24

monac24 commented Jul 16, 2026

Copy link
Copy Markdown
Author

/cr

@claude

claude Bot commented Jul 16, 2026

Copy link
Copy Markdown

Claude Code is working…

I'll analyze this and get back to you.

View job run

@claude

claude Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@monac24
monac24 merged commit 5088a73 into boon Jul 16, 2026
140 of 143 checks passed
@monac24
monac24 deleted the fix/msteams-surface-graph-400-body branch July 16, 2026 21:25
@monac24 monac24 changed the title fix(msteams): surface the Bot Framework/Graph HTTP body on send failures fix(msteams): surface the Bot Framework/Graph HTTP body on send failures ENG-16131 Jul 16, 2026
monac24 added a commit that referenced this pull request Jul 16, 2026
Bump version to capture on top of boon.3:
- #53 (ENG-15627 §5b/G4): report true operation outcome, not false terminal
  failure — kill/remove + non-terminal tool errors.
- #54: surface the Bot Framework/Graph HTTP body on msteams send failures.

Base = 2026.6.11-boon.3 (1bfc850). No code change in this commit — version bump
only; the fixes are already merged on boon.

Co-authored-by: Claude Opus 4.8 <[email protected]>
monac24 added a commit that referenced this pull request Jul 16, 2026
The prepack changelog gate (scripts/package-changelog.mjs) requires a matching
## <version> section; the boon.4 version bump (#57) omitted it, failing
boon-release.yml at the pack step. Add the section (#53 operation-outcome, #54
msteams send-failure body). Verified locally: extractCurrentPackageChangelog finds it.

Co-authored-by: Claude Opus 4.8 <[email protected]>
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