Repository navigation
Conversation
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
32e0a07 to
036c6ad
Compare
|
Rebased onto I re-checked that the fix is still needed rather than assuming. let data = match body.get("data") {
Some(d) => d,
None => return make_error("Missing 'data' field in response".to_string()),
};which is exactly the path #6402 hits — the live response is a top-level array with no
|
The GLM Coding Plan card renders nothing for some accounts even though the
request itself succeeds — a custom extractor script against the same
endpoint shows the quota fine.
`zhipu_quota_from_body` requires `body.data`, and `parse_zhipu_token_tiers`
then requires `data.limits`. `GET /api/monitor/usage/quota/limit` has also
been observed returning the limit list as a bare top-level array, with no
envelope at all:
[
{"type":"CREDIT_LIMIT","unit":3,"percentage":9,"nextResetTime":...},
{"type":"CREDIT_LIMIT","unit":6,"percentage":41,"nextResetTime":...}
]
Against that body `body.get("data")` is None, so the parser returns
"Missing 'data' field in response" and the card has nothing to show.
Look for the limit array where it actually is, instead of pinning one
envelope shape: the bare array, or a `limits` array on whatever object we
were handed. A body with no limits anywhere still reports an error, so a
genuinely broken response is not silently turned into an empty quota.
The `CREDIT_LIMIT` half of the report is already handled — the type filter
accepts it alongside `TOKENS_LIMIT` — so this only covers the envelope.
Refs farion1231#6402
036c6ad to
a2ab436
Compare
Refs #6402.
What happens
The GLM Coding Plan card renders no tiers at all for some accounts, while the request itself succeeds — pointing a custom extractor script at the same endpoint shows the quota fine. So the transport is healthy; the built-in parser is what drops the data.
Why
zhipu_quota_from_bodyrequiresbody.data:and
parse_zhipu_token_tiersthen requiresdata.limits.GET /api/monitor/usage/quota/limithas also been observed returning the limit list as a bare top-level array, with no envelope at all. From the dump in the issue:[ {"type":"CREDIT_LIMIT","unit":3,"number":5,"usage":28000,"currentValue":2585,"remaining":25414,"percentage":9,"nextResetTime":1786592963348}, {"type":"CREDIT_LIMIT","unit":6,"number":1,"usage":140000,"currentValue":58386,"remaining":81613,"percentage":41,"nextResetTime":1786692650981} ]Against that body
body.get("data")isNone, so the parser returnsMissing 'data' field in responsebefore it ever looks at the entries.Scope note
The issue titles the
CREDIT_LIMITtype filter, but that half is already fixed onmain— the filter acceptsCREDIT_LIMITalongsideTOKENS_LIMIT, case-insensitively. The part that still reproduces is the envelope, which the reporter flagged separately at the end of the report. This PR covers only that, henceRefsrather thanFixes.Change
Find the limit array where it actually is, rather than pinning one envelope shape — the bare array, or a
limitsarray on whatever object we were handed.unit-based window classification and every other behaviour is untouched.A body with no limits anywhere still returns an error, so a genuinely broken response is not silently converted into an empty-but-successful quota.
Tests
Three added:
zhipu_quota_reads_a_top_level_limit_array— the reporter's real response verbatim, asserting both tiers and their percentageszhipu_quota_reads_limits_without_a_data_envelope—{ "limits": [...] }with nodatazhipu_quota_still_reports_a_body_with_no_limits_anywhere— an unrecognised body must still surface an errorReverting the two source hunks and leaving the tests in place fails both new envelope tests with
error: Some("Missing 'data' field in response")— the exact symptom from the report.All 20 pre-existing
zhipu*tests still pass unchanged.cargo test --lib: 2480 passed, 2 failed. Both failures arecodex_config::tests::resolve_catalog_rejects_symlink_escaping_config_dirandservices::session_usage_grokbuild::tests::symlink_cycle_does_not_cause_stack_overflow, which panic withOs { code: 1314, "A required privilege is not held by the client." }— Windows refuses symlink creation without elevation, and they fail identically on the base commit.cargo fmt --checkandcargo clippy --lib --all-features -- -D warningsare clean.