fix: prevent telemetry interceptor from masking transport errors in extendToM365#15782
Closed
Alive-Fish wants to merge 2 commits intorelease/6.9from
Closed
fix: prevent telemetry interceptor from masking transport errors in extendToM365#15782Alive-Fish wants to merge 2 commits intorelease/6.9from
Alive-Fish wants to merge 2 commits intorelease/6.9from
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)
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
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.methodundefined → no throw.requestobject → no throw.response.data→ no throw.convertUrlToApiName(_, undefined)→ no throw.convertMethodUrlToApiDefForMOS(undefined, _)→ no throw.Testing
All 20
wrappedAxiosClient.test.tstests pass locally.Bug: AB#37640864
Related: #15676