Skip to content

[0.76] [Telemetry] Bug fix in codedError.data from trackException()#14238

Merged
danielayala94 merged 3 commits intomicrosoft:0.76-stablefrom
danielayala94:backportCodedErrorDataBugFix
Jan 7, 2025
Merged

[0.76] [Telemetry] Bug fix in codedError.data from trackException()#14238
danielayala94 merged 3 commits intomicrosoft:0.76-stablefrom
danielayala94:backportCodedErrorDataBugFix

Conversation

@danielayala94
Copy link
Copy Markdown
Contributor

@danielayala94 danielayala94 commented Jan 4, 2025

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, codedError contains relevant information about an exception thrown from the RNW CLI.
There are two ways to populate codedError: either a errorUtils.CodedError object is passed to trackException(), or a MSBuild error was hit, and the Error object contains any of the following fields: errno, syscall or code. It's in the second scenario where things go wrong.

In trackException(), codedErrorStruct copies the exception data from the Error object that was passed as parameter. This corresponds to codedError.data in the telemetry envelope. However, the MSBuild info was attempted to be copied into codedError.data.codedError.data, causing the Telemetry instance to throw.

Screenshots

N/A

Testing

Added a unit test that makes use of a CustomErrorTest object, based on Error but different from CodedError, 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

…rosoft#14191)

* Bug fix

* Simplify fix, add unit test

* Change files

* Nit: change test description
@danielayala94 danielayala94 requested review from a team as code owners January 4, 2025 00:21
@danielayala94 danielayala94 merged commit 3384ef8 into microsoft:0.76-stable Jan 7, 2025
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.

2 participants