fix(server): usage hubs with a host-less URL no longer vanish from Limits#11368

merged7
main
fix/server-usage-source-empty-label
openedSep 12, 2026bySshivam
View on GitHubTwo-way sync enabledPR last imported 13d ago

Refs #10193 (doesn't fix it: the reconnect loop there didn't reproduce)

A usage hub saved with a URL that has no scheme, such as localhost:8317, silently disappears from Usage → Limits. Node parses that URL with an empty host, so the hub's label is empty. The label fails to encode, and the server drops that hub from the list it sends to clients. There's no error anywhere, and other hubs keep working.

When the parsed host is empty, the label now falls back to the hub's ID (or "Usage limit source" if the ID is blank), so the hub shows up on Usage → Limits with its error. This doesn't change or repair the saved URL.

GPT-6 via Codex in T3 Code.

Summary by CodeRabbit

  • Bug Fixes

    • Improved usage-limit source labels when configured URLs are missing, malformed, or lack a host.
    • Uses a clear fallback label instead of displaying an unprocessed source identifier.
  • Tests

    • Added coverage confirming malformed source URLs remain supported in configuration updates.
    • Verified source labels, management-key validation errors, and prevention of unexpected network requests.

Real-app retest on current code (Oct 14, 2026)

Fresh worktrees of current main and this branch, web app on a dev server each. Settings → Providers → Usage providers: added a hub with URL localhost:8317 and one with https://hub.test:8318, then opened Usage → Limits.

Main: only hub.test:8318 shows; the localhost:8317 hub is silently missingThis PR: both hubs show, the bad one labeled by its ID (cliproxy-hub)

Both hubs are saved in Settings on both builds:

MainThis PR

The valid hub keeps its host as the label on both builds. No client disconnect or reconnect, console error or server error on either build.

Checks

23 successful · 10 skipped
All checks passed
cba258a
Synced from GitHub

Approvability

Verdict: Approved at 98bacc9

Macroscope's review found this PR approvable — This is a narrowly scoped server bug fix that keeps usage-source snapshots schema-valid for malformed or hostless URLs, preventing configuration-stream disconnects while preserving valid labels and existing management-key behavior. The added test is development-only and covers the affected service and event-encoding path.

No code changes detected at cba258a. Prior analysis still applies.

You can add or adjust custom eligibility rules. Learn more.

Synced from GitHub

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ProviderMetricMain baselineThis PRImpactPR ceiling
CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
CodexLive turn WebSocket decoded20.9 KiB20.9 KiB0 B (0.0%)29.3 KiB✅
CodexLive turn messages220 (0.0%)8✅
ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB0 B (0.0%)29.3 KiB✅
ClaudeLive turn messages220 (0.0%)8✅

Baseline: 11fd54f · PR result: cba258a · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

Synced from GitHub

Bugbot is paused — on-demand spend limit reached

Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

Synced from GitHub

Review Change StackReview Change Stack

Important

Review skipped

We couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting @coderabbitai full review.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: a79d67c3-3c4f-48ad-a0aa-5d6d39c85865

📥 Commits

Reviewing files that changed from the base of the PR and between 20363c32c9bfdbf49c2716ef11d1f18483fcc01b and 324a644269d5838e4a72d151bba38938e6477fbe.

📒 Files selected for processing (2)
  • apps/server/src/usage/UsageLimitSources.test.ts
  • apps/server/src/usage/UsageLimitSources.ts

Limit details: You’ve used all 10 included reviews currently available.

📝 Walkthrough

The change updates usage-limit source labels for invalid or hostless URLs. It adds an effect-based test that verifies source snapshots remain encodable in ServerConfigStreamEvent updates.

Changes: Usage limit source handling

Layer / File(s)Summary
Source label fallback and encoding validation
apps/server/src/usage/UsageLimitSources.ts, apps/server/src/usage/UsageLimitSources.test.ts
sourceLabel now uses a trimmed source ID or "Usage limit source" when a URL is invalid or has no host. The test verifies labels, missing management-key errors, snapshot encoding, and disabled network activity.

Priority: ⬇️ Low

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

Change: Bug fix

Suggested reviewers: juliusmarminge

Merge Risk: ⚪ Minimal · up to 2e354

Malformed or hostless usage source URLs now receive safe non-empty labels while preserving source errors, with regression coverage for configuration-event encoding. No merge-blocking risk is identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check nameStatusExplanationResolution
Docstring CoverageWarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check nameStatusExplanation
Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
Title checkPassedThe title clearly and concisely describes the main fix: usage hubs with host-less URLs remain visible in Limits.
Description checkPassedThe description clearly explains the problem, the fallback behavior, the unchanged URL handling, and the verification results with before-and-after evidence. It does not use the template headings exac…
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/server-usage-source-empty-label

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

Added 1 commit

  • fix(server): keep malformed usage sources from disconnecting clientsed9b5b4

Added 2 commits

  • Merge branch 'main' into fix/server-usage-source-empty-label6d84f71
  • test(server): update usage source test for the Effect 4 upgrade98bacc9

Added 4 commits

  • Merge branch 'main' into fix/server-usage-source-empty-labeledb3604
  • Merge branch 'main' into fix/server-usage-source-empty-labeld444bd5
  • Merge branch 'main' into fix/server-usage-source-empty-labela27d51e
  • Merge branch 'main' into fix/server-usage-source-empty-labelcba258a