-
Notifications
You must be signed in to change notification settings - Fork 143
Description
Problem
We're tracking scanned repositories and their results in a database, but the implementation has issues:
- Multiple pagination searches - After creating/updating issues or PRs, we search through all issues/PRs again to find the URL
- Test failures - Tests crash with nil pointer errors
- Verbose error handling - Database save functions require verbose error handling at every call site
Solution
Use Go's context pattern to communicate action results (issue/PR URLs) from the action functions back to the caller.
Implementation Progress
β Completed
-
Created context helper -
pkg/policies/action/actionresult.goWithActionResult(ctx)- wraps context to track resultsSetActionURL(ctx, url)- stores URL in contextGetActionResult(ctx)- retrieves stored URL
-
Updated issue package -
pkg/issue/issue.go- callsaction.SetActionURL()after creating/updating issues -
Updated pullrequest package -
pkg/pullrequest/pullrequest.go- callsaction.SetActionURL()after creating/updating PRs -
Updated enforce.go - wraps context, retrieves URL from context, deleted
getIssueURL()andgetPRURL()functions -
Enhanced database logging - both save functions now log errors internally
π In Progress
Simplify database error handling - Remove verbose error handling at 6+ call sites in pkg/enforce/enforce.go
Lines to fix: 162, 222, 388, 419, 468, 505
β³ Remaining
Update tests - Fix test mocks in pkg/enforce/enforce_test.go
Files Modified
- β
pkg/policies/action/actionresult.go- new file - β
pkg/issue/issue.go - β
pkg/pullrequest/pullrequest.go - β
pkg/enforce/enforce.go- partial - π
pkg/enforce/enforce.go- error handling cleanup needed - β³
pkg/enforce/enforce_test.go- mocks need updating
Metadata
Metadata
Assignees
Labels
Type
Projects
Status