Repository navigation
fix(cloud): wake 401 refusals record which token check failed; auth-refusals floor - #48570
Conversation
97d2dab to
4b6072d
Compare
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
4b6072d to
47b0ff4
Compare
|
@coderabbitai review |
Action performed
|
…efusals needs 5 refusals and 200 upgrades - A refused wake token's refuse metric gets a sixth blob, detail: the jose check that failed (exp, nbf, iat, aud, iss, sub, signature, kid, alg), or claims, malformed, host, missing or other. Fixed values only: nothing read from the token. reason stays 'token', so existing queries and the alerts' refuse_401 column are unchanged. On 2026-11-24 two hosts (GRU, FRA) were refused repeatedly after a refresh and the dataset could not say why; exp or nbf would point at clock skew. - auth-refusals (share of upgrades) now needs at least 5 refusals beyond the alerts' own probes and at least AUTH_MIN_UPGRADES upgrades (default 200, never below MIN_VOLUME); below that floor auth-refusals-low-volume needs the same 5. Before, 2 refusals in 36 upgrades paged at MIN_VOLUME 20. Neither rule fires on 2026-11-24 production, before or after.
47b0ff4 to
754bbf5
Compare
ELI5
When the wake Worker turns away a desktop's token, it now records why (expired, not valid yet, wrong audience, unknown key, and so on), not just "token". Separately, the auth-refusal alert no longer pages on a couple of refusals in a quiet window.
What Changed
cloud/apps/connector-wake/src/jwt.ts,index.ts,metrics.ts):verifyWakeTokenreturns acodefor an invalid token, from a fixed set,WAKE_REFUSE_CODES:claim:exp,nbf,iat,aud,iss,sub,signature,kid(no matching key),alg,malformed;claims(schema/purpose),host(not a host id),missing(no bearer),other.refusemetric writes it as a new sixth blob,detail. Every other metric writes''there.reasonstaystoken, so the alerts'refuse_401column and any existing query are unchanged.alerts-rules.ts):auth-refusals(more than 0.5% of upgrades refused) now also needs at least 5 refusals beyond the alerts' own probes, and at leastAUTH_MIN_UPGRADESupgrades (default 200, never belowMIN_VOLUME).auth-refusals-low-volumetakes over with the same 5-refusal bar, so there's no gap between the two.Why
token. Anexpornbfdetail would have pointed straight at clock skew between auth and the colo.MIN_VOLUME20, 2 refusals in 36 upgrades (5.6%) pagedauth-refusals, and so did 2 in 306 (0.65%). One host with a bad token isn't worth a page.Linked Issue
N/A (internal)
Visual Proof
N/A: cloud Worker metrics and alert rules, no UI.
Testing
test/auth.test.ts:aud, purpose →claims, bad host id →claims;exp;nbf5 min ahead →nbf; unknownkid→kid; another key →signature; garbage →malformed;[refuse, 401, version, token, place, code]and other events get''.test/alerts.test.ts:auth-refusals; 5 at 109 →auth-refusals-low-volume;AUTH_MIN_UPGRADESoverride, never belowMIN_VOLUME.expmapping fails the codes test.vitest run test/alerts.test.ts test/auth.test.ts(27 passed) andtsc --noEmit(clean).iatonly undermaxTokenAge, which the Worker doesn't set. A token from a clock that runs ahead is refused only if it carriesnbf. The test pins that, and I didn't change what the Worker accepts.Performance
None, because the refuse path only adds one class check on an error that already happened, and every metric gains one empty string blob.
Risk
Level: Low.
cloud/connector-wake-source-revisionin stablyai/orca-cloud is bumped, with Jinwoo's OK.mainbeside fix(cloud): wake reconnect-surge ignores object retirement waves, still fires on real drops #48497 and touches different lines ofalerts-rules.tsand its test.