Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 7 minutes and 11 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
Walkthrough새로운 구독(subscription) 기능을 추가합니다. CLI 명령어는 설정에서 기본 URL과 API 키를 읽고, API 클라이언트를 통해 사용자의 구독 정보를 조회하며, 요금제 이름, 사용/총 크레딧, 남은 크레딧, 동시성 제한을 표준 출력으로 표시합니다. Changes
Sequence DiagramsequenceDiagram
participant User as 사용자
participant CLI as CLI 명령어
participant Client as HTTP 클라이언트
participant API as API 서버
User->>CLI: subscription 명령 실행
CLI->>CLI: 설정에서 base_url, api_key 읽기
CLI->>Client: NewWithBaseURL() 또는 New()로 클라이언트 생성
CLI->>Client: GetMySubscription() 호출
Client->>API: GET /v1/users/me/subscription
API-->>Client: JSON 응답 (요금제, 크레딧, 제한)
Client->>Client: JSON 언마셜링
Client-->>CLI: SubscriptionResponse 반환
CLI->>CLI: remaining = PlanCredits - UsedCredits 계산
CLI->>CLI: formatInt()로 정수 포맷팅
CLI->>User: 요금제명, 사용/총 크레딧, 남은 크레딧, 동시성 제한 출력
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
internal/client/subscription_test.go (1)
54-57: 인증 실패 테스트에서 에러 종류까지 고정해 주세요.Line 55-57은
err != nil만 확인해서, 인증 에러 매핑이 깨져도 테스트가 통과할 수 있습니다. 인증 실패 메시지(또는 핵심 prefix)까지 확인하는 편이 안전합니다.테스트 보강 예시
import ( "encoding/json" "net/http" + "strings" "testing" ) @@ _, err := c.GetMySubscription() if err == nil { t.Fatal("expected error, got nil") } + if !strings.Contains(err.Error(), "authentication failed") { + t.Fatalf("unexpected error: %v", err) + } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@internal/client/subscription_test.go` around lines 54 - 57, The test around c.GetMySubscription() currently only asserts err != nil; update it to assert the specific authentication error by checking the error value or message (e.g., using errors.Is(err, ErrAuthentication) or strings.HasPrefix(err.Error(), "authentication")/expected prefix) so that authentication error mapping is validated; locate the test in subscription_test.go where GetMySubscription() is called and replace the loose nil-check with a concrete assertion against the expected auth error symbol or message.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@cmd/subscription.go`:
- Around line 42-43: The negative branch in formatInt triggers infinite
recursion for math.MinInt64 because -math.MinInt64 overflows; fix by avoiding
negation on int64: either explicitly handle the sentinel (if n == math.MinInt64
return "-9223372036854775808") or convert to unsigned before magnitude
processing (e.g., set var u uint64; if n < 0 { u = uint64(-(n + 1)) + 1 } else {
u = uint64(n) } ) and then use u for the remaining formatting logic in
formatInt; update imports to include math only if you choose the sentinel
constant check.
---
Nitpick comments:
In `@internal/client/subscription_test.go`:
- Around line 54-57: The test around c.GetMySubscription() currently only
asserts err != nil; update it to assert the specific authentication error by
checking the error value or message (e.g., using errors.Is(err,
ErrAuthentication) or strings.HasPrefix(err.Error(), "authentication")/expected
prefix) so that authentication error mapping is validated; locate the test in
subscription_test.go where GetMySubscription() is called and replace the loose
nil-check with a concrete assertion against the expected auth error symbol or
message.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d07191ab-6187-4551-b858-467f97e87ba0
📒 Files selected for processing (3)
cmd/subscription.gointernal/client/subscription.gointernal/client/subscription_test.go
Use strconv.FormatInt instead of negating the value, which overflows when n == math.MinInt64 since -MinInt64 cannot be represented in int64.
Summary
Adds
cast subscriptioncommand to display the authenticated user's plan, credit usage, and concurrency limits viaGET /v1/users/me/subscription.Usage
Output:
Changes
internal/client/subscription.go:GetMySubscription()method + response typesinternal/client/subscription_test.go: 2 tests (success + unauthorized)cmd/subscription.go: cobra subcommand with formatted outputTest plan
go test ./...passesSummary by CodeRabbit
릴리스 노트
새로운 기능
테스트