[0.76] [Telemetry] Bug fix in codedError.data from trackException()#14238
Merged
danielayala94 merged 3 commits intomicrosoft:0.76-stablefrom Jan 7, 2025
Merged
Conversation
…rosoft#14191) * Bug fix * Simplify fix, add unit test * Change files * Nit: change test description
TatianaKapos
approved these changes
Jan 6, 2025
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.
Description
Backports #14191 to 0.76.
This PR eliminates the risk of writing into undefined struct fields in
trackException().Type of Change
Bug fix
Why
Error telemetry instances were lost when hitting MS Build errors sometimes, plus avoid unnecesssary CLI error noise.
Resolves #14184
What
One-line change:
codedErrorStruct.data[f] = (error as any)[f];instead of:
codedErrorStruct.data.codedError.data[f] = (error as any)[f];Context:
In error telemetry instances,
codedErrorcontains relevant information about an exception thrown from the RNW CLI.There are two ways to populate
codedError: either aerrorUtils.CodedErrorobject is passed totrackException(), or a MSBuild error was hit, and theErrorobject contains any of the following fields:errno,syscallorcode. It's in the second scenario where things go wrong.In
trackException(),codedErrorStructcopies the exception data from theErrorobject that was passed as parameter. This corresponds tocodedError.datain the telemetry envelope. However, the MSBuild info was attempted to be copied intocodedError.data.codedError.data, causing the Telemetry instance to throw.Screenshots
N/A
Testing
Added a unit test that makes use of a
CustomErrorTestobject, based onErrorbut different fromCodedError, to re-create the conditions where the bug was caught.Changelog
Yes - Fix bug in error telemetry collection.
Microsoft Reviewers: Open in CodeFlow
Microsoft Reviewers: Open in CodeFlow