fix: prevent telemetry interceptor from masking transport errors in extendToM365 (cherry-pick to dev)#15785
Merged
Alive-Fish merged 2 commits intodevfrom Apr 23, 2026
Merged
Conversation
…xtendToM365 - Wrap WrappedAxiosClient.onRejected in try/catch so any defect in telemetry can never replace the real transport-level error returned to the caller. - Guard error.request?.method/host/path - transport errors (TLS handshake, ECONNRESET on a kept-alive socket, socket hang up) can have these undefined. - Guard method.toUpperCase() in convertUrlToApiName and convertMethodUrlToApiDefForMOS. - Tolerate non-object error.response.data (e.g. HTML 502 body) in the MOS branch. - Add 5 regression tests covering undefined method, missing request object, and string response.data. Bug: AB#37640864 Related: #15676 (keepAlive + retry exposed this latent bug)
Adds 5 more regression tests exercising: - AppStudio TDP error without headers - MOS error with nested response.data.error - MOS error with empty inner error fields - telemetry-reporter throwing (exercises outer try/catch) - minimal error shape with no config / no message Brings src/common/wrappedAxiosClient.ts branch coverage from ~92.6% to 95.9% and line coverage to 100% for the changed code.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #15785 +/- ##
==========================================
+ Coverage 93.29% 93.31% +0.01%
==========================================
Files 585 585
Lines 37006 37012 +6
Branches 6928 6934 +6
==========================================
+ Hits 34526 34536 +10
Misses 1836 1836
+ Partials 644 640 -4
🚀 New features to boost your workflow:
|
HuihuiWu-Microsoft
approved these changes
Apr 23, 2026
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.
Cherry-pick of #15782 (release/6.9 → dev).
Summary
Fixes AB#37640864.
When
provisionrunsteamsApp/extendToM365under network latency, the user sees a misleading error:instead of the real MOS/network failure (TLS handshake, ECONNRESET, "socket hang up", etc.).
Root cause
The Axios telemetry interceptor
WrappedAxiosClient.onRejectedcallsconvertUrlToApiName(fullPath, method), which doesmethod.toUpperCase(). For low-level transport errors,error.request.methodis oftenundefined, so the interceptor itself throws a syntheticTypeErrorthat propagates out ofPackageServiceand replaces the real error.PR #15676 (keepAlive + 3-attempt retry on
extendToM365) is what surfaced this latent bug:keepAlive: truereuses sockets that the server may have silently closed, producing exactly the "method undefined" class of AxiosError.TypeErroris thrown — matching the bug report's "failed by retry 3 times".Changes
packages/fx-core/src/common/wrappedAxiosClient.tsonRejectedbody intry { … } catch {}so telemetry can never replace the original error.error.request?.method/host/path.method.toUpperCase()inconvertUrlToApiNameandconvertMethodUrlToApiDefForMOS.error.response.data(e.g. HTML 502 body) in the MOS branch.error.response.headers[CORRELATION_ID]lookup safe when headers is missing.packages/fx-core/tests/common/wrappedAxiosClient.test.tsrequest.method, missingrequestobject, stringresponse.data, AppStudio TDP error without headers, MOS error with nestedresponse.data.error, MOS error with empty inner error fields, telemetry-reporter throwing (outer try/catch), and minimal error shape.Testing
All 25
wrappedAxiosClient.test.tstests pass. Branch coverage on the changed file: 95.9%; line coverage: 100%.Bug: AB#37640864
Related: #15676, #15782