Skip to content

[0.64.0] Preserve Grok billing defaults - #594

Merged
Finesssee merged 1 commit into
mainfrom
codex/port-0.64.0-grok-billing
Sep 22, 2026
Merged

Finesssee merged 1 commit into
mainfrom
codex/port-0.64.0-grok-billing

Conversation

@Finesssee

@Finesssee Finesssee commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • send Grok's billing RPC as a nonempty gRPC-web request that explicitly encodes exclude_legacy_monthly_usage=false
  • preserve fallback from an expired OAuth credential to the configured local Grok token
  • add request-contract and fallback regressions

Upstream reference: bb62d35532cc08d7016d7a03605d8adcf67d5ddd (fix(grok): preserve billing defaults in nonempty requests).

Validation

  • cargo fmt --all
  • cargo test --manifest-path rust/Cargo.toml providers::grok::tests --lib (18 passed)
  • cargo clippy --manifest-path rust/Cargo.toml --lib --tests -- -D warnings
  • git diff --check

This lane is dependency-free and is based directly on main.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed billing requests when credits are not explicitly included, improving usage percentage reporting.
    • Improved billing and usage retrieval when OAuth authentication fails by retrying with the configured local authentication token.
    • Updated billing request handling to ensure compatibility with the service’s expected request format.

@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: e1c226a7-6214-44dd-9803-b377e4ef68f0

📥 Commits

Reviewing files that changed from the base of the PR and between 8cdd2ca and a3dd63b.

📒 Files selected for processing (2)
  • rust/src/providers/grok/mod.rs
  • rust/src/providers/grok/tests.rs

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The Grok provider now uses a configurable billing endpoint and a non-empty gRPC-web request body. OAuth billing authentication fallback is centralized and retries with the configured local token after an authentication failure. Tests cover both behaviors.

Changes

Grok billing and authentication

Layer / File(s) Summary
Configurable billing request
rust/src/providers/grok/mod.rs, rust/src/providers/grok/tests.rs
GrokProvider stores a configurable billing endpoint. fetch_billing uses the updated gRPC-web body. Tests verify the request bytes and parsed billing percentage.
OAuth billing fallback
rust/src/providers/grok/mod.rs, rust/src/providers/grok/tests.rs
fetch_with_oauth_fallback centralizes the OAuth retry with a bearer token from ctx.api_key. fetch_usage uses this method, and a test verifies the local-token retry.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to a3dd6

The billing request preserves the explicit default, and OAuth billing can fall back to the configured local token after authentication failure. No merge-blocking production risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.46% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: preserving Grok billing defaults. It matches the billing request behavior changes in the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Thermo-nuclear code-quality review

Verdict: PASS — no actionable maintainability findings.

The change keeps billing behavior inside the Grok provider, extracts OAuth fallback into a focused policy method, and adds a narrow HTTP test seam. Neither touched file crosses 1,000 lines, and the patch adds no scattered provider-specific branching or duplicate implementation path.

@Finesssee
Finesssee merged commit d33daf4 into main Sep 22, 2026
4 checks passed
@Finesssee
Finesssee deleted the codex/port-0.64.0-grok-billing branch September 22, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant