fix(api): resolve Go vet errors#953
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | -146 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Greptile SummaryThis PR performs a mechanical, codebase-wide cleanup to resolve
Confidence Score: 4/5The changes are purely mechanical vet-compliance fixes with no altered business logic; safe to merge with minor concerns about test coverage. All format-string and BSON-key changes are safe and consistent. The handler tests tagged as integration are genuinely localhost-dependent, but there is no CI step that will re-run them with the tag, so coverage of those three test cases is silently lost. api/pkg/handlers/handler_test.go and api/pkg/handlers/phone_api_key_handler_test.go — the integration build tag removes them from all automated test runs. Important Files Changed
Reviews (1): Last reviewed commit: "fix(api): resolve Go vet errors" | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
This PR updates the Go API codebase to eliminate go vet diagnostics by switching away from pre-formatted fmt.Sprintf(...) messages and toward direct formatted calls to palantir/stacktrace, fixing a few vet-detected issues (e.g., BSON composite literals), and marking localhost-dependent handler tests as integration-only.
Changes:
- Replace
fmt.Sprintf(...)/fmt.Errorf(...)preformatting with formattedstacktrace.Propagate/NewError/...calls across services, handlers, repositories, validators, listeners, middleware, and cache. - Fix vet-related MongoDB BSON literal usage by using keyed
bson.E{Key:..., Value:...}elements. - Add
//go:build integrationtags to handler tests that depend on localhost/integration setup.
Reviewed changes
Copilot reviewed 86 out of 86 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| api/pkg/validators/validator.go | Use errors.New for cached validation errors to avoid unintended formatting. |
| api/pkg/validators/user_handler_validator.go | Use formatted stacktrace.Propagate without preformatting. |
| api/pkg/validators/turnstile_token_validator.go | Avoid preformatted strings in propagated stacktrace errors. |
| api/pkg/validators/message_handler_validator.go | Avoid preformatted strings in propagated stacktrace errors. |
| api/pkg/validators/discord_handler_validator.go | Replace preformatted messages with formatted stacktrace calls. |
| api/pkg/validators/bulk_message_handler_validator.go | Replace preformatted messages with formatted stacktrace calls. |
| api/pkg/telemetry/gorm_logger.go | Use formatted stacktrace propagation for GORM trace errors. |
| api/pkg/services/service.go | Avoid preformatted strings in stacktrace propagation. |
| api/pkg/services/phone_service.go | Avoid preformatted strings in stacktrace propagation. |
| api/pkg/services/phone_api_key_service.go | Avoid preformatted strings in stacktrace propagation. |
| api/pkg/services/message_thread_service.go | Avoid preformatted strings in stacktrace propagation. |
| api/pkg/services/message_send_schedule_service.go | Avoid preformatted strings in stacktrace propagation (including multiline calls). |
| api/pkg/services/marketting_service.go | Avoid preformatted strings in stacktrace propagation. |
| api/pkg/services/lemonsqueezy_service.go | Avoid preformatted strings in stacktrace propagation and new errors. |
| api/pkg/services/integration_3cx_service.go | Avoid preformatted strings in stacktrace propagation and new errors. |
| api/pkg/services/google_cloud_push_queue_service.go | Avoid duplicate preformatted error messages; use formatted propagation. |
| api/pkg/services/event_dispatcher_service.go | Avoid preformatted strings in stacktrace propagation, including subscriber failures. |
| api/pkg/services/entitlement_service.go | Avoid preformatted strings in stacktrace propagation. |
| api/pkg/services/emulator_push_queue.go | Avoid preformatted strings in stacktrace propagation. |
| api/pkg/services/emulator_fcm_client.go | Avoid preformatted strings in stacktrace propagation. |
| api/pkg/services/email_notification_service.go | Avoid preformatted strings in stacktrace propagation across notification paths. |
| api/pkg/services/discord_service.go | Avoid preformatted strings in stacktrace propagation. |
| api/pkg/services/billing_service.go | Avoid preformatted strings in stacktrace propagation and logging. |
| api/pkg/requests/message_receive_request.go | Fix Owner assignment to match *phonenumbers.PhoneNumber type. |
| api/pkg/repositories/mongodb.go | Use keyed BSON elements for index definitions; avoid preformatted stacktrace messages. |
| api/pkg/repositories/mongo_heartbeat_repository.go | Use keyed BSON elements; avoid preformatted stacktrace messages. |
| api/pkg/repositories/mongo_heartbeat_monitor_repository.go | Use keyed BSON elements; avoid preformatted stacktrace messages. |
| api/pkg/repositories/memory_attachment_repository.go | Avoid preformatted strings in stacktrace new-error-with-code usage. |
| api/pkg/repositories/gorm_webhook_repository.go | Avoid preformatted strings in stacktrace propagation. |
| api/pkg/repositories/gorm_user_repository.go | Avoid preformatted strings in stacktrace propagation; formatting refactor. |
| api/pkg/repositories/gorm_phone_repository.go | Avoid preformatted strings in stacktrace propagation. |
| api/pkg/repositories/gorm_phone_notification_repository.go | Avoid preformatted strings in stacktrace propagation; formatting refactor. |
| api/pkg/repositories/gorm_phone_api_key_repository.go | Avoid preformatted strings in stacktrace propagation. |
| api/pkg/repositories/gorm_message_thread_repository.go | Avoid preformatted strings in stacktrace propagation. |
| api/pkg/repositories/gorm_message_repository.go | Avoid preformatted strings in stacktrace propagation; formatting refactor. |
| api/pkg/repositories/gorm_integration_3cx_repository.go | Avoid preformatted strings in stacktrace propagation. |
| api/pkg/repositories/gorm_heartbeat_repository.go | Avoid preformatted strings in stacktrace propagation. |
| api/pkg/repositories/gorm_heartbeat_monitor_repository.go | Avoid preformatted strings in stacktrace propagation. |
| api/pkg/repositories/gorm_discord_repository.go | Avoid preformatted strings in stacktrace propagation. |
| api/pkg/repositories/gorm_billing_usage_repository.go | Avoid preformatted strings in stacktrace propagation; formatting refactor. |
| api/pkg/repositories/google_cloud_storage_attachment_repository.go | Avoid preformatted strings in stacktrace propagation, including not-found path. |
| api/pkg/middlewares/phone_api_key_auth_middleware.go | Avoid preformatted strings in stacktrace propagation. |
| api/pkg/middlewares/http_request_logger_middleware.go | Avoid preformatted strings in stacktrace new errors. |
| api/pkg/middlewares/bearer_auth_middleware.go | Avoid preformatted strings in stacktrace propagation. |
| api/pkg/middlewares/bearer_api_key_auth_middleware.go | Avoid preformatted strings in stacktrace propagation. |
| api/pkg/middlewares/api_key_auth_middleware.go | Avoid preformatted strings in stacktrace propagation. |
| api/pkg/listeners/websocket_listener.go | Avoid preformatted strings in stacktrace propagation across event decoding/triggering. |
| api/pkg/listeners/webhook_listener.go | Avoid preformatted strings in stacktrace propagation across event decoding/sending. |
| api/pkg/listeners/user_listener.go | Avoid preformatted strings in stacktrace propagation across event decoding/service calls. |
| api/pkg/listeners/phone_notification_listener.go | Avoid preformatted strings in stacktrace propagation across event decoding/service calls. |
| api/pkg/listeners/phone_listener.go | Avoid preformatted strings in stacktrace propagation across event decoding/service calls. |
| api/pkg/listeners/phone_api_key_listener.go | Avoid preformatted strings in stacktrace propagation; fix format specifier. |
| api/pkg/listeners/message_thread_listener.go | Avoid preformatted strings in stacktrace propagation across event decoding/service calls. |
| api/pkg/listeners/message_send_schedule_listener.go | Avoid preformatted strings in stacktrace propagation across event decoding/service calls. |
| api/pkg/listeners/marketing_listener.go | Avoid preformatted strings in stacktrace propagation across event decoding/service calls. |
| api/pkg/listeners/integration_3cx_listener.go | Avoid preformatted strings in stacktrace propagation across event decoding/service calls. |
| api/pkg/listeners/heartbeat_listener.go | Avoid preformatted strings in stacktrace propagation across event decoding/service calls. |
| api/pkg/listeners/email_notification_listener.go | Avoid preformatted strings in stacktrace propagation across event decoding/service calls. |
| api/pkg/listeners/discord_listener.go | Avoid preformatted strings in stacktrace propagation across event decoding/service calls. |
| api/pkg/listeners/billing_listener.go | Avoid preformatted strings in stacktrace propagation across event decoding/service calls. |
| api/pkg/handlers/webhook_handler.go | Avoid preformatted strings in stacktrace usage for bind/validation/service errors. |
| api/pkg/handlers/user_handler.go | Avoid preformatted strings in stacktrace usage for bind/validation/service errors. |
| api/pkg/handlers/phone_handler.go | Avoid preformatted strings in stacktrace usage for bind/validation/service errors. |
| api/pkg/handlers/phone_api_key_handler.go | Avoid preformatted strings in stacktrace usage for bind/validation/service errors. |
| api/pkg/handlers/phone_api_key_handler_test.go | Mark handler test file as integration-only via build tag. |
| api/pkg/handlers/message_thread_handler.go | Avoid preformatted strings in stacktrace usage for bind/validation/service errors. |
| api/pkg/handlers/message_send_schedule_handler.go | Avoid preformatted strings in stacktrace usage for service errors. |
| api/pkg/handlers/lemonsqueezy_handler.go | Avoid preformatted strings in stacktrace propagation and new errors. |
| api/pkg/handlers/integration_3cx_handler.go | Avoid preformatted strings in stacktrace usage for bind/service errors. |
| api/pkg/handlers/heartbeat_handler.go | Avoid preformatted strings in stacktrace usage for bind/validation/service errors. |
| api/pkg/handlers/handler_test.go | Mark handler test file as integration-only via build tag. |
| api/pkg/handlers/events_handler.go | Avoid preformatted strings in stacktrace usage for bind/validation/dispatch errors. |
| api/pkg/handlers/discord_handler.go | Avoid preformatted strings in stacktrace usage for bind/validation/service errors. |
| api/pkg/handlers/bulk_message_handler.go | Avoid preformatted strings in stacktrace usage for upload/validation/send errors. |
| api/pkg/handlers/billing_handler.go | Avoid preformatted strings in stacktrace usage for bind/validation/service errors. |
| api/pkg/handlers/attachment_handler.go | Avoid preformatted strings in stacktrace usage for download errors. |
| api/pkg/di/container.go | Avoid preformatted strings in stacktrace fatal errors during DI initialization/migrations. |
| api/pkg/cache/redis_cache.go | Avoid preformatted strings in stacktrace propagation from Redis errors. |
| api/pkg/cache/memory_cache.go | Avoid preformatted strings in stacktrace new errors from cache misses. |
Make printf-like error wrapping explicit for Go 1.26, use keyed BSON elements, and keep live-server handler tests out of the unit suite. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5e77d279-9f4a-46bc-97b1-db6975c76faf
Pass format strings and arguments directly instead of formatting messages twice. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5e77d279-9f4a-46bc-97b1-db6975c76faf
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5e77d279-9f4a-46bc-97b1-db6975c76faf
Keep localhost-dependent handler coverage active in the Docker integration job. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5e77d279-9f4a-46bc-97b1-db6975c76faf
Keep logged IDs, limits, and regex details aligned with the operations that failed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5e77d279-9f4a-46bc-97b1-db6975c76faf
64cb72f to
67a7a67
Compare
| } | ||
|
|
||
| return h.responseBadRequest(c, stacktrace.NewError(fmt.Sprintf("unknown type [%d]", payload["type"]))) | ||
| return h.responseBadRequest(c, stacktrace.NewError("unknown type [%d]", payload["type"])) |
Summary
Testing
cd api && go vet ./...cd api && go test ./...