Commit bc258f6
authored
fix(cline-pass): correct upstream-id reverse map and API base path
Follows PR #122 (squash-merged to dev as commit 8a23432) with two
bug fixes that surfaced after deployment.
Bug 1 — empty WebUI quota card (deployment 2026-07-11 ~02:34 UTC):
The quota tracker's _build_billing_url() defensively stripped a
trailing /v1 from the resolved base, producing the wrong URL:
https://api.cline.bot/api/users/me/plan/usage-limits
instead of the correct documented path:
https://api.cline.bot/api/v1/users/me/plan/usage-limits
The upstream call 404'd, no baselines landed in UsageManager, and
the /v1/quota-stats filter (total_requests == 0 and no quota data)
dropped the provider entirely from the response.
Fix: removed the trailing-/v1 strip in _build_billing_url. The
Cline API is a flat /api/v1 namespace — the helper just joins
base + path. Also unified provider routing on self.api_base so
chat completions, model discovery, and quota polling all hit
the same documented /api/v1/... prefix.
Root cause: first cut conflated 'OpenAI-compatible body' with
'OpenAI-compatible path prefix'. Cline's API is rooted at /api/v1/,
not /v1/.
Bug 2 — upstream-id double-prefix (Kilo Code review on PR #122):
_build_reverse_map wrapped the already-prefixed upstream ids
(`cline-pass/glm-5.2`) with `cline_pass/` again, producing
double-prefixed keys (`cline_pass/cline-pass/glm-5.2`) that
`normalize_model_for_tracking` never matched. As a result, raw
upstream ids from Cline error messages and quota breakdowns
were passed through unchanged instead of being mapped to the
proxy's display names — breaking the very 'WebUI/pricing maps
upstream → display' feature the original PR description called
out.
Umans does not have this bug because its UMANS_MODELS upstream
ids are bare (`umans-kimi-k2.6`); wrapping with `umans/`
produces a valid reverse-map key. ClinePass cannot reuse that
trick because the upstream ids already include the `cline-pass/`
prefix.
Fix: _build_reverse_map stores the raw upstream id as the key
(no proxy prefix wrapping) and the proxy display name
(`cline_pass/<bare>`) as the value. normalize_model_for_tracking
handles all three caller-input shapes (raw upstream id, proxy
display name, bare) and returns the canonical display name.
Stack compliance:
Adds a `cline-pass` entry under `allowed_duplicate_features` in
`.fork/stack.yml` since this is a `fix()` companion to the
existing `feat(cline-pass):` commit on dev. The xai and umans
feature areas already follow this pattern.
Regression coverage (10 new tests, all pass):
test_build_billing_url_default_base_passes_path_through
test_build_billing_url_preserves_v1_in_api_v1_base
test_build_billing_url_trailing_slash_on_base_is_normalised
test_provider_api_base_default_uses_documented_upstream
test_provider_uses_single_api_base_for_both_models_and_chat
test_build_reverse_map_keys_are_raw_upstream_ids
test_normalize_model_from_raw_upstream_id
test_normalize_model_from_proxy_display_name
test_normalize_model_from_bare_name
test_normalize_model_unknown_returns_input
The test_provider_* tests pin both the documented upstream URLs
and the single-base invariant so a future split between
quota/chat/models bases will fail CI loudly instead of silently
404'ing in production.
Verification:
uv run python3 -m py_compile — passed (all 3 changed Python files)
uv run ruff check --select F401,F811,F821,E9 — passed
uv run --with pytest python3 -m pytest tests/test_cline_pass_quota_tracker.py -q
— 34 passed
uv run --with pytest --with pytest-asyncio python3 -m pytest tests/ -q
— 493 passed (+3 from this branch); same 15 pre-existing setup
errors and same 2 pre-existing umans/xai test failures as dev
(unrelated to this PR).
Files (5):
src/rotator_library/providers/cline_pass_provider.py
src/rotator_library/providers/utilities/cline_pass_quota_tracker.py
tests/test_cline_pass_quota_tracker.py
.fork/stack.yml
.fork/features/cline-pass.md1 parent 8a23432 commit bc258f6
5 files changed
Lines changed: 176 additions & 24 deletions
File tree
- .fork
- features
- src/rotator_library/providers
- utilities
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
29 | 33 | | |
30 | 34 | | |
31 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
81 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
82 | 84 | | |
83 | | - | |
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
| |||
152 | 153 | | |
153 | 154 | | |
154 | 155 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | 156 | | |
159 | 157 | | |
160 | 158 | | |
| |||
371 | 369 | | |
372 | 370 | | |
373 | 371 | | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
374 | 375 | | |
375 | 376 | | |
376 | | - | |
| 377 | + | |
377 | 378 | | |
378 | 379 | | |
379 | 380 | | |
380 | | - | |
| 381 | + | |
381 | 382 | | |
382 | 383 | | |
383 | 384 | | |
| |||
Lines changed: 13 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
152 | 159 | | |
153 | 160 | | |
154 | 161 | | |
| |||
158 | 165 | | |
159 | 166 | | |
160 | 167 | | |
161 | | - | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
162 | 173 | | |
163 | 174 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | 175 | | |
168 | 176 | | |
169 | 177 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
66 | 76 | | |
67 | 77 | | |
68 | | - | |
| 78 | + | |
69 | 79 | | |
70 | 80 | | |
71 | 81 | | |
72 | | - | |
73 | | - | |
| 82 | + | |
| 83 | + | |
74 | 84 | | |
75 | 85 | | |
76 | 86 | | |
77 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
78 | 91 | | |
79 | 92 | | |
80 | | - | |
| 93 | + | |
81 | 94 | | |
82 | 95 | | |
83 | | - | |
84 | 96 | | |
85 | | - | |
86 | | - | |
| 97 | + | |
| 98 | + | |
87 | 99 | | |
88 | 100 | | |
89 | 101 | | |
| |||
95 | 107 | | |
96 | 108 | | |
97 | 109 | | |
98 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
99 | 124 | | |
100 | 125 | | |
101 | 126 | | |
| |||
607 | 632 | | |
608 | 633 | | |
609 | 634 | | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
0 commit comments