fix(go): Correct Go module import paths - #2118
Conversation
WalkthroughImport paths in the controller file have been updated from local module aliases ( Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
controller/topup_creem.go (3)
40-42: Security risk: Signature verification bypassed in test mode.In test mode, webhook signature verification is completely skipped. This allows any webhook request to be processed without authentication, potentially enabling unauthorized payment confirmations. Even in test environments, webhooks should be validated against a test secret to maintain security guarantees and catch integration issues.
102-102: Critical: Unchecked error could cause panic.The error from
GetUserByIdis ignored, and theuserobject is used without checking if it's nil. If the user lookup fails, accessinguser.Id,user.Email, oruser.Usernameon lines 105, 125 will cause a nil pointer dereference panic.Apply this diff to handle the error:
- user, _ := model.GetUserById(id, false) + user, err := model.GetUserById(id, false) + if err != nil || user == nil { + log.Printf("获取用户信息失败: %v", err) + c.JSON(200, gin.H{"message": "error", "data": "用户信息获取失败"}) + return + }
423-423: Privacy concern: User email logged in plaintext.User email (PII) is logged directly, while Line 319 redacts customer email. For GDPR/privacy compliance, mask or redact the email here as well.
Apply this diff:
- log.Printf("发送Creem支付请求 - URL: %s, 产品ID: %s, 用户邮箱: %s, 订单号: %s", - apiUrl, product.ProductId, email, referenceId) + log.Printf("发送Creem支付请求 - URL: %s, 产品ID: %s, 用户邮箱: <redacted>, 订单号: %s", + apiUrl, product.ProductId, referenceId)
🧹 Nitpick comments (2)
controller/topup_creem.go (2)
156-156: Gate verbose logging behind test mode.Logging the full request body may expose sensitive payment data in production logs. Consider restricting this to test mode only.
Apply this diff:
- // 打印body内容 - log.Printf("creem pay request body: %s", string(bodyBytes)) + // 打印body内容(仅在测试模式) + if setting.CreemTestMode { + log.Printf("creem pay request body: %s", string(bodyBytes)) + }
442-442: Gate API response logging behind test mode.The full API response may contain sensitive information. Consider restricting this detailed logging to test mode only.
Apply this diff:
- log.Printf("Creem API resp - status code: %d, resp: %s", resp.StatusCode, string(body)) + if setting.CreemTestMode { + log.Printf("Creem API resp - status code: %d, resp: %s", resp.StatusCode, string(body)) + } else { + log.Printf("Creem API resp - status code: %d", resp.StatusCode) + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
controller/topup_creem.go(1 hunks)
🔇 Additional comments (1)
controller/topup_creem.go (1)
13-15: LGTM! Import paths corrected.The import paths have been properly updated to match the module path in go.mod, resolving the build errors.
fix(go): Correct Go module import paths
…agination-localStorage fix: 恢复表格分页大小 localStorage 持久化
This PR (Pull Request) fixes the Go build errors that occurred after changing the repository URL.
Problem
The
docker buildcommand was failing with errors like:This was caused by an inconsistency between the module path defined in
go.mod(github.com/QuantumNous/new-api) and the import paths used in the source code, which still referred to the old module name (one-api).Solution
This change replaces all old import references (
"one-api/...") with the new, module-compliant ones ("github.com/QuantumNous/new-api/...") across all Go files in the project.Result
This resolves the build errors and allows the Docker image to be built successfully.
Summary by CodeRabbit