Skip to content

fix(api): resolve Go vet errors#953

Merged
AchoArnold merged 5 commits into
mainfrom
fix/go-vet-test-errors-go126
Jul 18, 2026
Merged

fix(api): resolve Go vet errors#953
AchoArnold merged 5 commits into
mainfrom
fix/go-vet-test-errors-go126

Conversation

@AchoArnold

@AchoArnold AchoArnold commented Jul 18, 2026

Copy link
Copy Markdown
Member

Summary

  • use palantir stacktrace format strings directly instead of preformatting messages
  • use keyed BSON elements and fix genuine format-string and protobuf lock-copy diagnostics
  • mark localhost-dependent handler tests as integration-only

Testing

  • cd api && go vet ./...
  • cd api && go test ./...

@codacy-production

codacy-production Bot commented Jul 18, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · -146 duplication

Metric Results
Complexity 0
Duplication -146

View in Codacy

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-apps

greptile-apps Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR performs a mechanical, codebase-wide cleanup to resolve go vet diagnostics that were introduced or tightened in Go 1.26. No business logic is changed.

  • stacktrace.Propagate format-string fix: Every call of the form stacktrace.Propagate(err, msg) across ~80 files is updated to stacktrace.Propagate(err, \"%s\", msg) so the message variable is treated as a plain string argument rather than a format string, silencing the printf-family vet checker.
  • Keyed BSON composite literals: All bson.D{{...}} composite literals in the MongoDB repositories are updated to use explicit Key:/Value: field names, fixing the composites vet diagnostic.
  • fmt.Errorferrors.New: Bare fmt.Errorf(variable) calls in validators/validator.go are replaced with errors.New(variable), and the integration build tag //go:build integration is added to the two handler test files that depend on a running localhost:8000 server.

Confidence Score: 4/5

The 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

Filename Overview
api/pkg/repositories/mongo_heartbeat_monitor_repository.go Keyed BSON elements and format-verb fix in all stacktrace.Propagate calls — mechanical, correct
api/pkg/repositories/mongo_heartbeat_repository.go Keyed BSON elements and format-verb fix — consistent with sister repository file
api/pkg/repositories/mongodb.go Keyed BSON index definitions and stacktrace.Propagate format-verb fix — mechanically correct
api/pkg/validators/validator.go Replaces fmt.Errorf(errMsg) with errors.New(errMsg) to fix vet warnings; residual fmt.Sprintf on constant strings not cleaned up
api/pkg/handlers/handler_test.go Adds //go:build integration to exclude localhost-dependent handler tests from standard go test ./...; these tests are no longer run in CI
api/pkg/handlers/phone_api_key_handler_test.go Adds //go:build integration tag; three TestPhoneAPIKeyHandler_* tests now excluded from standard and CI test runs
api/pkg/services/service.go Format-verb fixes to stacktrace.Propagate calls in shared service helpers — clean and correct
api/pkg/services/heartbeat_service.go Comprehensive format-verb fix across all stacktrace.Propagate calls — mechanically correct
api/pkg/di/container.go Format-verb fixes to stacktrace.Propagate calls in DB migration and Firebase initialization code — no logic change

Reviews (1): Last reviewed commit: "fix(api): resolve Go vet errors" | Re-trigger Greptile

Comment thread api/pkg/validators/validator.go
Comment thread api/pkg/handlers/handler_test.go

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 formatted stacktrace.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 integration tags 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.

Comment thread api/pkg/validators/discord_handler_validator.go
Comment thread api/pkg/validators/discord_handler_validator.go
Comment thread api/pkg/services/service.go Outdated
Comment thread api/pkg/repositories/gorm_user_repository.go
Comment thread api/pkg/handlers/webhook_handler.go
Comment thread api/pkg/handlers/integration_3cx_handler.go
AchoArnold and others added 5 commits July 18, 2026 11:56
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
@AchoArnold
AchoArnold force-pushed the fix/go-vet-test-errors-go126 branch from 64cb72f to 67a7a67 Compare July 18, 2026 08:57
@AchoArnold
AchoArnold requested a review from Copilot July 18, 2026 09:05
@AchoArnold
AchoArnold merged commit 8a03f4f into main Jul 18, 2026
13 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

}

return h.responseBadRequest(c, stacktrace.NewError(fmt.Sprintf("unknown type [%d]", payload["type"])))
return h.responseBadRequest(c, stacktrace.NewError("unknown type [%d]", payload["type"]))
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