Skip to content

feat(quota): decode GeminiApiErrorDetails quota reset time, RPM/daily metric, and verification status #364

Not planned

Description

@lawrancehoy-cyber

想要什么,用来做什么 / What you want and what for

改动 / Changes

AI Studio RPC error responses include type.googleapis.com/google.internal.alkali.applications.makersuite.v1.GeminiApiErrorDetails (_.Go in m_b.js), which decodeRPCErrorMetadata previously skipped (only parsing google.rpc.RetryInfo and google.rpc.ErrorInfo):

  • internal/aistudio/client.go:
    • Decode GeminiApiErrorDetails in decodeRPCErrorMetadata:
      • field 29 (index 28, QuotaFailure Hyb): extract violations[0][3] -> Metadata["quota_metric"] and violations[0][4] -> Metadata["quota_limit"] (quotaId).
      • field 33 (index 32, google.protobuf.Timestamp [seconds, nanos]): decode exact QuotaResetAt (zCa in m_b.js).
      • field 41 (index 40): set AccountVerificationRequired = true so RPCError.accessDenial() unwraps to camoufoxnative.ErrAccountVerification structurally even if the error text changes.
  • internal/aistudio/quota.go:
    • Classify daily quota metrics (Iyb in m_b.js: generate_requests_per_model_per_user, generate_content_tokens_per_model_per_user, predict_requests_per_model_per_user, predict_long_running_generations_per_model_per_user_per_day, scaled_predict_long_running_generations_per_model_per_user_per_day) as DailyLimitKind when quota_limit does not contain PerMinute.
    • Use rpcError.QuotaResetAt directly as the cooldown Until timestamp when RetryDelay is absent (avoiding blind 1-minute escalation or Pacific-midnight guessing).
  • internal/aistudio/rpc_error_details_test.go: unit tests covering daily metric + exact reset timestamp, PerMinute override, and field 41 ErrAccountVerification unwrapping.

验证 / Verification

  • go test -mod=readonly -trimpath -count=1 ./internal/aistudio/... ./internal/api/... (internal/aistudio 0.048s, internal/api 0.091s) — passed.
  • go vet -mod=readonly ./internal/aistudio/... ./internal/api/... ./internal/i18n/... — passed.

  • 修改涉及的所有代码均在本地实际跑通过,没有只靠肉眼检查
  • 所有新增或修改的逻辑均有对应的测试覆盖
  • 已阅读并理解仓库的整体结构,没有破坏现有架构或引入重复实现

版本 / Version

v0.3.17 (5deae85)

Activity

  1. github-actions commented on Dec 3, 2026

    @github-actions

    每人最多同时打开 3 个 Issue,这个 Issue 已自动关闭。请等已有的 Issue 处理完再提,或把内容补充到已有的 Issue 里。

    Each user can have at most 3 open issues at a time, so this one was closed automatically. Please wait until your existing issues are resolved, or add this to one of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions