Repository navigation
Conversation
|
Thanks for this. The retry itself works: the two new tests fail on main's 1. Every 403 in the
To reproduce, add these at the end of test("PROBE credential 403, no refresh token", async () => {
const stub = stubFetch({ statusBody: { message: "invalid token" }, statusStatus: 403 });
try {
const plugin = await AtomCodePlugin({}, { locale: "en", autoVersion: false });
const usage = await plugin.auth.usage(async () => AUTH);
console.log("calls", stub.calls.filter((c) => c.url.includes("status-v2")).length, usage.signIn);
} finally { stub.restore(); }
});
test("PROBE quota 403", async () => {
const stub = stubFetch({ statusBody: { message: "CodingPlan quota exhausted" }, statusStatus: 403 });
try {
const plugin = await AtomCodePlugin({}, { locale: "en", autoVersion: false });
await plugin.auth.usage(async () => ({ ...AUTH, refresh: "r", expires: Date.now() + 3600_000 }));
console.log("calls", stub.calls.filter((c) => c.url.includes("status-v2")).length);
} finally { stub.restore(); }
});On macOS with Bun 1.4.2:
2. The sleep doesn't check the poll budget. What to change } catch (error) {
if (isCredentialFailure(error) && credentials.refresh) {
// the existing forceRefresh path, unchanged
} else if (
error?.status === 403 &&
classifyError(error, { stage: "usage" }).category === FAILURE.FORBIDDEN &&
(remainingMs(deadline) ?? Infinity) > STATUS_FORBIDDEN_BACKOFF_MS + 1_000
) {
await sleep(STATUS_FORBIDDEN_BACKOFF_MS);
status = await readStatus(credentials, 7_000);
} else {
throw error;
}
}( Nits (optional):
Windows reds: |
… body only - usage: a 403 with no credential/entitlement words gets one short backoff retry inside the same poll, bounded by the deadline; quota and credential 403s keep their existing paths (yetone's review of magpie-community#2032) - new statusForbiddenBackoffMs option (default 1500, 0 disables) so tests skip the wait - codingplan.mjs: classify upstream errors by the body's own message — the wrapped 'CodingPlan returned HTTP …' prefix tripped the entitlement word list and mislabeled every 403 - package.json: keep the one-line version diff (whitespace hunk dropped per review)
|
All points addressed, pushed as 991342d:
One extra fix that came out of re-testing against #6's actual shape: macOS/Windows numbers match your table (Windows: the same 7 environment fails at main and at this head, none from this PR). |
|
Thanks for the follow-up. I ran this head (991342d) with probes against stubbed fetch, in Bun 1.4.2 on Linux with a fresh HOME. Main is 104f886. I'm not merging yet, for these reasons:
On a side note, your 4 new tests behave as they should against main's index.mjs. The two retry tests go red on main and the two "no retry" tests pass there, so they guard what they name. Once 1 is answered and 2 and 3 are fixed, I'll review again. |
A 403 on the usage poll's status-v2 read (token-rotation race or a one-off policy probe) used to land on the diagnostics page as a bare 'forbidden · HTTP 403' next to an otherwise green window. One short backoff retry settles the transient case inside the same poll; a persistent 403 still surfaces with its upstream message. Reported with a green window in aqiu817/magpie-atomcode#6; the chat loader keeps its existing refresh-once behavior.
… body only - usage: a 403 with no credential/entitlement words gets one short backoff retry inside the same poll, bounded by the deadline; quota and credential 403s keep their existing paths (yetone's review of magpie-community#2032) - new statusForbiddenBackoffMs option (default 1500, 0 disables) so tests skip the wait - codingplan.mjs: classify upstream errors by the body's own message — the wrapped 'CodingPlan returned HTTP …' prefix tripped the entitlement word list and mislabeled every 403 - package.json: keep the one-line version diff (whitespace hunk dropped per review)
991342d to
15f4666
Compare
Summary
The quota poll (
auth.usage→status-v2) now retries a lone non-credential 403 once after a short backoff, instead of immediately surfacing it on the diagnostics page.Context
aqiu817/magpie-atomcode#6 reported a bare "forbidden · HTTP 403" on the diagnostics page while the account was connected, the catalog pulled fine and chat requests all succeeded — a single rejected
status-v2read at a token-rotation boundary, self-healing on the next poll. The chat loader already refreshes once on 401/credential-403; the usage poll had no equivalent, so one transient rejection stuck on the page for a full minute.Changes
usage: on a 403 whose body carries no credential/entitlement words, wait a short backoff and re-readstatus-v2once within the same poll budget; a 403 that persists still surfaces with its upstream messageVerification
bun test packages/atomcode— new cases pass; the 5 tests failing on this Windows checkout (CLI sign-in path handling, browser OAuth error text) fail identically onmainwithout this changebun scripts/check.mjs atomcode✓