Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR updates asynchronous operations to use a background context and inject a logger for email and notification routines.
- Imported
contextandgo.uber.org/zapto support context propagation and structured logging. - Refactored the welcome email goroutine to use
context.Background()and attach a*zap.SugaredLogger. - Updated all task notification goroutines to create a background context with logger instead of passing the Gin context.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/apis/user.go | Added context and logger imports; wrapped SendWelcomeEmail in a background context goroutine with logger injection. |
| internal/apis/task.go | Imported zap; replaced notification goroutines to use background context with logger and removed direct use of Gin context. |
Comments suppressed due to low confidence (5)
internal/apis/task.go:214
- There are no tests covering the new async notification logic or its context and logger propagation. Consider adding unit tests or integration tests to verify that notifications run with the correct context and include structured logs.
go func(task *models.Task, logger *zap.SugaredLogger) {
internal/apis/user.go:102
- The variable
logis not defined in this scope, causing a compilation error. Consider retrieving or injecting the logger (e.g.,logger := zap.L().Sugar()or adding aloggerfield on the handler) before passing it into the goroutine.
}(signupReq.DisplayName, signupReq.Email, code, log)
internal/apis/task.go:217
- The
logidentifier is undefined here. You should obtain the SugaredLogger instance (for example viazap.L().Sugar(), a handler field, or Gin context) before passing it into the goroutine.
}(createdTask, log)
internal/apis/user.go:100
- Using a plain string as a context key can lead to collisions. Define a custom key type (e.g.,
type ctxKeyLogger struct{}) and use an unexported key value to safely store the logger in the context.
ctx := context.WithValue(context.Background(), "logger", logger)
internal/apis/task.go:214
- [nitpick] This goroutine pattern is repeated across multiple handlers. Consider extracting a helper function (e.g.,
spawnWithLogger(ctx, task, h.nRepo.GenerateNotifications)) to reduce duplication and improve readability.
go func(task *models.Task, logger *zap.SugaredLogger) {
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
dkhalife
added a commit
that referenced
this pull request
Oct 5, 2025
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
Summary
Testing
go vet ./...go test ./...https://chatgpt.com/codex/tasks/task_e_686b37defc9c832aa49e75dae7ac373e