Skip to content

Conversation

@prestonvasquez
Copy link
Member

Copilot AI review requested due to automatic review settings November 18, 2025 01:13
@prestonvasquez prestonvasquez requested a review from a team as a code owner November 18, 2025 01:13
@prestonvasquez prestonvasquez marked this pull request as draft November 18, 2025 01:13
@prestonvasquez prestonvasquez removed the request for review from qingyang-hu November 18, 2025 01:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR extends the CommandFailedEvent structure to include error codes, addressing GODRIVER-3690. The change enables users to access error codes directly from command failure events without parsing the error themselves.

Key changes:

  • Added a Codes field to CommandFailedEvent to expose error codes
  • Implemented errorCodes() helper function to extract codes from driver errors
  • Added test coverage for the new field

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
event/monitoring.go Added Codes field to CommandFailedEvent structure
x/mongo/driver/operation.go Populates the new Codes field when publishing failed events; removed blank line
x/mongo/driver/errors.go Implemented errorCodes() function to extract error codes from driver errors
mongo/errors.go Refactored variable declarations to use var() block (style change)
internal/integration/clam_prose_test.go Added test case for CommandFailedEvent.Codes; removed blank line

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +581 to +584
if driversErr, ok := err.(Error); ok {
return []int32{driversErr.Code}
}

Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type assertion should use the modern syntax with type parameter. Change err.(Error) to use a type switch or keep the current form but consider that direct type assertion without pointer check may not catch *Error types. Verify if both Error and *Error need to be handled.

Suggested change
if driversErr, ok := err.(Error); ok {
return []int32{driversErr.Code}
}
switch e := err.(type) {
case Error:
return []int32{e.Code}
case *Error:
if e != nil {
return []int32{e.Code}
}
}

Copilot uses AI. Check for mistakes.
@mongodb-drivers-pr-bot
Copy link
Contributor

🧪 Performance Results

Commit SHA: 86d0004

The following benchmark tests for version 691bc82b7c8b8a000704f85a had statistically significant changes (i.e., |z-score| > 1.96):

Benchmark Measurement % Change Patch Value Stable Region H-Score Z-Score
BenchmarkBSONDeepDocumentDecoding ops_per_second_min 22.8587 2461.0599 Avg: 2003.1621
Med: 2006.7145
Stdev: 170.0300
0.8144 2.6930
BenchmarkBSONFullDocumentDecoding allocated_bytes_per_op 0.0346 25331.0000 Avg: 25322.2308
Med: 25321.0000
Stdev: 3.9191
0.8273 2.2376

For a comprehensive view of all microbenchmark results for this PR's commit, please check out the Evergreen perf task for this patch.

@mongodb-drivers-pr-bot
Copy link
Contributor

API Change Report

./v2/event

incompatible changes

CommandFailedEvent: old is comparable, new is not

compatible changes

CommandFailedEvent.Codes: added

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