Skip to content

fix: Type error in UserQuotaSnapshot (PR #507 CI fix)#513

Closed
github-actions[bot] wants to merge 1 commit intofix/daily-quota-timezone-consistencyfrom
claude-fix-pr-507-1767390138
Closed

fix: Type error in UserQuotaSnapshot (PR #507 CI fix)#513
github-actions[bot] wants to merge 1 commit intofix/daily-quota-timezone-consistencyfrom
claude-fix-pr-507-1767390138

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Jan 2, 2026

CI Auto-Fix

Original PR: #507
Failed CI Run: Non-Main Branch CI/CD

Problem

TypeScript compilation failed on fix/daily-quota-timezone-consistency branch:

Type error: Type '{ rpm: { limit: number | null; ... }; ... }' 
is not assignable to type 'UserQuotaSnapshot'.
  The types of 'rpm.limit' are incompatible.
    Type 'number | null' is not assignable to type 'number'.

Root Cause

The timezone consistency fixes in commit ce9b616 correctly changed getUserLimitUsage() to return limit: number | null, but the UserQuotaSnapshot interface was not updated to match. User quotas CAN be null (meaning unlimited).

Fixes Applied

File Change Reason
types.ts:4 rpm.limit: numbernumber | null Quotas can be unlimited (null)
types.ts:5 dailyCost.limit: numbernumber | null Quotas can be unlimited (null)
types.ts:5 resetAt?: DateresetAt: Date Always present in runtime

Verification

  • bun run build succeeds
  • ✅ TypeScript compilation passes
  • ✅ No logic changes made
  • ✅ Type definitions now match actual runtime data

Changes

 export interface UserQuotaSnapshot {
-  rpm: { current: number; limit: number; window: "per_minute" };
-  dailyCost: { current: number; limit: number; resetAt?: Date };
+  rpm: { current: number; limit: number | null; window: "per_minute" };
+  dailyCost: { current: number; limit: number | null; resetAt: Date };
 }

Auto-generated by Claude AI

Greptile Summary

This CI auto-fix resolves a TypeScript compilation error by aligning the UserQuotaSnapshot interface with the actual return type of getUserLimitUsage().

Changes made:

  • rpm.limit: numbernumber | null (quotas can be unlimited)
  • dailyCost.limit: numbernumber | null (quotas can be unlimited)
  • resetAt?: DateresetAt: Date (always present at runtime, returned by getDailyResetTime())

Root cause: PR #507 correctly updated getUserLimitUsage() to return nullable limits (matching the database schema where rpmLimit and dailyLimitUsd are nullable integers/numerics), but the consuming interface was not updated.

Verification:

  • Database schema confirms users.rpm_limit and users.daily_limit_usd are nullable
  • getDailyResetTime() always returns a non-null Date object
  • Consuming code in users-quota-client.tsx and user-quota-list-item.tsx already handles null limits correctly with null-checks (e.g., limit !== null && limit > 0)
  • No logic changes, purely type alignment

Confidence Score: 5/5

  • This PR is safe to merge with no risk - it's a type-only fix that aligns interfaces with runtime behavior
  • Score of 5 reflects that this is a pure TypeScript type correction with zero runtime impact. The changes correctly match the database schema (nullable limits) and actual function return types. All consuming code already handles null values properly with explicit null-checks. The build passes and no logic was modified.
  • No files require special attention

Important Files Changed

Filename Overview
src/app/[locale]/dashboard/quotas/users/_components/types.ts Type-only fix: correctly allows `limit: number

Sequence Diagram

sequenceDiagram
    participant UI as Users Quota Page
    participant Action as getUserLimitUsage()
    participant DB as Database
    participant Redis as Redis Cache
    participant Type as UserQuotaSnapshot

    UI->>Action: Request user quota (userId)
    Action->>DB: findUserById(userId)
    DB-->>Action: User { rpmLimit: int | null, dailyLimitUsd: numeric | null }
    Action->>Redis: Get RPM current (dynamic window)
    Redis-->>Action: 0 (cannot get exact value)
    Action->>DB: sumUserCostToday(userId)
    DB-->>Action: dailyCost: number
    Action->>Action: getDailyResetTime()
    Action-->>UI: { rpm: { limit: number | null }, dailyCost: { limit: number | null, resetAt: Date } }
    UI->>Type: Type check UserQuotaSnapshot
    Note over Type: ✅ BEFORE: limit: number (mismatch)<br/>✅ AFTER: limit: number | null (matches)<br/>✅ resetAt: Date (always present)
Loading

… type

Fixed:
- Changed rpm.limit from 'number' to 'number | null' (quotas can be unlimited)
- Changed dailyCost.limit from 'number' to 'number | null'
- Changed dailyCost.resetAt from 'Date | undefined' to 'Date' (always present)

Type mismatch was exposed by timezone consistency fixes in ce9b616.
The getUserLimitUsage() function returns user.rpm and user.dailyQuota which can be null.

CI Run: https://github.com/ding113/claude-code-hub/actions/runs/20667174342
@ding113 ding113 closed this Jan 3, 2026
@github-project-automation github-project-automation bot moved this from Backlog to Done in Claude Code Hub Roadmap Jan 3, 2026
@ding113 ding113 deleted the claude-fix-pr-507-1767390138 branch January 27, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant