Repository navigation
Go: Update error info - #16619
Go: Update error info#16619
Conversation
Signed-off-by: Jin Hai <[email protected]>
📝 WalkthroughWalkthroughThis PR modifies ChangesEnterprise Service Not-Supported Conversion
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
internal/admin/enterprise_service.go (2)
1058-1070: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick winDo not echo the API key in delete responses.
DeleteUserAPIKeyincludes the rawkeyvalue in the response map even though the operation is unsupported. Avoid reflecting secrets in API payloads.Proposed fix
result := map[string]interface{}{ "command": "delete_user_api_key", "email": user.Email, "nickname": user.Nickname, - "api_key": key, - "error": "'Delete user API key' is not supported", + "error": "'delete user API key' is not supported", }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/admin/enterprise_service.go` around lines 1058 - 1070, DeleteUserAPIKey is echoing the raw API key in its response payload, which should be removed. Update the result map built in Service.DeleteUserAPIKey so it no longer includes the key field, while keeping the existing command, email, nickname, and error values unchanged. Keep the unsupported-operation behavior intact and ensure no secret values are reflected in the returned map.
257-265: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick winDo not echo
newAPIKeyin the unsupported response.
AlterProviderInstancereceivesreq.APIKeyfrom the handler and returns it asnew_api_key, so a failed/unsupported admin call can expose the provider secret back through the API response. Remove the field or return only a masked/boolean indicator.Proposed fix
return map[string]interface{}{ "command": "alter_provider_instance", "user_id": userID, "provider_id": providerName, "instance_name": instanceName, "new_instance_name": newInstanceName, - "new_api_key": newAPIKey, "error": "'alter provider instance' is not supported", }, nil🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/admin/enterprise_service.go` around lines 257 - 265, The unsupported response from AlterProviderInstance is echoing the sensitive newAPIKey value back to the caller. Update the Service.AlterProviderInstance return payload to remove the new_api_key field entirely or replace it with a non-sensitive indicator (for example, a boolean or masked value), and keep the rest of the command metadata unchanged.
🧹 Nitpick comments (1)
internal/admin/enterprise_service.go (1)
829-829: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winNormalize the unsupported message casing.
Earlier messages use lowercase command text (
'list roles' is not supported), but these use leading capitals ('List users reports'...). Since this PR updates user-facing error strings, keep the format consistent.Also applies to: 843-843, 857-857, 871-871, 901-901, 912-912, 923-923, 934-934, 945-945, 956-956, 967-967, 978-978, 990-990, 1009-1009, 1033-1033, 1051-1051, 1089-1089, 1104-1104, 1126-1126, 1148-1148
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/admin/enterprise_service.go` at line 829, Normalize the user-facing unsupported error strings in enterprise_service.go so they match the existing lowercase command-text style used elsewhere, such as the messages built in the related report/list helper branches; update the string literals returned for the affected unsupported cases (including the one in the List Users Reports path and the other referenced branches) to use lowercase command names consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@internal/admin/enterprise_service.go`:
- Around line 1058-1070: DeleteUserAPIKey is echoing the raw API key in its
response payload, which should be removed. Update the result map built in
Service.DeleteUserAPIKey so it no longer includes the key field, while keeping
the existing command, email, nickname, and error values unchanged. Keep the
unsupported-operation behavior intact and ensure no secret values are reflected
in the returned map.
- Around line 257-265: The unsupported response from AlterProviderInstance is
echoing the sensitive newAPIKey value back to the caller. Update the
Service.AlterProviderInstance return payload to remove the new_api_key field
entirely or replace it with a non-sensitive indicator (for example, a boolean or
masked value), and keep the rest of the command metadata unchanged.
---
Nitpick comments:
In `@internal/admin/enterprise_service.go`:
- Line 829: Normalize the user-facing unsupported error strings in
enterprise_service.go so they match the existing lowercase command-text style
used elsewhere, such as the messages built in the related report/list helper
branches; update the string literals returned for the affected unsupported cases
(including the one in the List Users Reports path and the other referenced
branches) to use lowercase command names consistently.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e005332a-b460-4cc8-89dd-740518fc36dd
📒 Files selected for processing (1)
internal/admin/enterprise_service.go
As title. Signed-off-by: Jin Hai <[email protected]>
As title. Signed-off-by: Jin Hai <[email protected]>
As title.