Skip to content

Conversation

sonalmahajan15
Copy link
Contributor

This PR refines the error wrapping heuristic to cover:

  • return of new error from input string message (e.g., return NewInternalServerError("some error message"))
  • nested error wrapping calls (e.g., return Wrapf(Wrapf(Wrapf(NewError(err.Error())))))

Copy link

codecov bot commented Oct 16, 2025

Codecov Report

❌ Patch coverage is 86.95652% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.47%. Comparing base (361559d) to head (df77675).

Files with missing lines Patch % Lines
util/util.go 45.45% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #369      +/-   ##
==========================================
- Coverage   87.60%   87.47%   -0.13%     
==========================================
  Files          73       73              
  Lines       10848    10864      +16     
==========================================
  Hits         9503     9503              
- Misses       1155     1167      +12     
- Partials      190      194       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Golden Test

Note

✅ NilAway errors reported on standard libraries are identical.

2548 errors on base branch (main, 361559d)
2548 errors on test branch (4765c7b)

for sig, act := range _assumeReturns {
if sig.match(pass, call) {
return act(call)
return act(call), true
Copy link
Contributor

Choose a reason for hiding this comment

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

trigger's nilability implies this boolean value, right? shouldn't we just do that?

Comment on lines +552 to +568
func IsError(pass *analysishelper.EnhancedPass, expr ast.Expr) bool {
t := pass.TypesInfo.TypeOf(expr)
if t == nil {
return false
}
// Check if expr represents an implementation of the error interface
return implementsError(t)
}

// implementsError checks if the given object implements the error interface. It also covers the case of
// interfaces that embed the error interface.
func implementsError(t types.Type) bool {
if ErrorInterface == nil {
return false
}
return types.Implements(t, ErrorInterface)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

can we attach these directly to analysishelper.EnhancedPass such that we do not have to pass it around?

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