An Azure subscription with a spending limit (a student's $100 a month,
a trial's) is disabled by Azure when its credit runs out and enabled
again on its own when the credit renews. Meanwhile every request 401s
"Access denied due to invalid subscription key or wrong API endpoint",
the words a wrong key gets. magpie read that as any 401: failOther on
the 1-minute backoff climbing to 10 minutes, never asked in the
background, so the key was asked again by requests for weeks, and the
reporter turned the provider off and on by hand around the reset day.
Now restAfterMarked reads a failOther 401 as failSuspended when
azureSuspended holds: no account, Provider.IsAzure, and the key has
answered a request before (provider.LastServed at provider.ServedID,
served.json, 30 days) or is resting suspended already. It rests
suspendedRest (a day) by "suspended", and probeable takes it whatever
its status: keepProbingRests asks the resource's deployments list with
the key at 1, 2, 5 and then every 10 minutes (refused the same while
the subscription is off) and lifts the rest as soon as the list answers,
or when a request does. Its group's requests go to the next member
meanwhile, Azure not asked.
Product calls (mine to make, delegated):
- One 401 is enough, not "repeated" ones: a 401 is about the credential,
never the model or the request content. On a key that worked, a
transient 401 is lifted by the first ask a minute in, the same as the
old one-minute backoff let it back.
- A bad key stays a bad key: a key 401 from its first request (new,
mistyped, or edited, its KeyID then another) has no answer on record
and rests as before, failOther/backoff, shown "401 · failed", never
asked in the background. served.json unreadable is no answer on
record too (a failed read is unknown, not "it worked").
- Azure only: a 401 says nothing of why on other vendors, and a list
that answers without the key (OpenRouter's is public) would lift a key
its vendor still refuses.
- No "back on day N" setting: the probe finds the day Azure enables the
subscription, so there is nothing for the user to type in, and no
Advanced field.
GUI: the key list says "Resting · 401 suspended by the vendor · back
at … · checked in the background, back as soon as it answers"; Routing's
restHow says its key answered before, so the vendor has most likely
suspended it (an Azure subscription out of credit). KEY_FAIL and the
routing plugin's FAIL gain "suspended", in en, zh, zh-TW, ja and de.
keyDead is unchanged, so "Remove failing" doesn't offer a suspended key.
docs/subsystems/gateway-routing.md has the rule beside the rest probe.
Not covered: a 403; a key whose last answer is over 30 days old after a
restart (rests are in memory); the last candidate of a request, which
rests only for quota, credit or a timed rate limit, so a lone Azure
provider is asked again by each request, as before, and answers as soon
as Azure does.
Run on mica (mote had other sessions' full suites), at b4c88d44e
unless named, rebased on 9fc1114d8 before the push:
- go test -tags nogui -run 'TestAzureKey|TestSuspended' ./internal/gateway:
ok. Broken by hand, each red: azureSuspended always false (3 red:
ThatAnswered, IsAzureOnly, OutlivesItsLastAnswer); served history
ignored, every Azure 401 suspended (NeverAnsweredIsABadKey and
OutlivesItsLastAnswer red); probeable's suspended branch off
(ThatAnswered, IsAzureOnly red).
- azure-suspended.test.cjs, chromium and webkit, en zh zh-TW ja de,
1100 and 420px: 40/40; with the base's four GUI assets, 0/40.
- At this head rebased, on mote (mica had another session's GUI suite):
rest-try-now, key-rest-date, rest-probed, azure-suspended,
routing-rest-off and i18n-keys, both engines: 146 of 164. All 18 reds
are rest-try-now's (#4127 "ebody holds", #2564), 18 of 40 at
origin/main 9fc1114d8 too. At b4c88d44e under load 47 on mica the
same files had 50 timeouts; at light load only rest-try-now's,
red on main too, are left.
- go test -count=3 -run 'TestAzureKey|TestSuspended|Probe|Rest'
./internal/gateway at this head rebased, on mote: ok.
- go vet ./internal/gateway ./internal/gui, and GOOS=linux and
GOOS=windows go vet ./internal/gateway: ok.
- go test -timeout 45m ./... in a sandbox HOME: the first run filled
mica's disk (another session's) and ~300 tests failed "no space left
on device". The six packages it touched, run again: agent and
provider ok, sessions ran past -timeout 45m with no test failed
(TestTitleOfALongPromptAllocatesItsTitle at the deadline, #5451; it
imports neither gateway nor gui); three reds, each filed and
none in code this changes:
- internal/dirent watch tests (#7031), red at origin/main 9fc1114d8
too.
- TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (#7117), red at
9fc1114d8 too.
- TestGatewayModeListsNoOwnSessions (#7064, the listing race): red
2 of 3 at b4c88d44e, ok 2 of 2 at 9fc1114d8 and 4 of 4 at this head
rebased.
Not tried: a real Azure subscription disabled for its credit (none to
hand); the list's 401 while disabled is from Azure's documented
behaviour that the data plane refuses a disabled subscription's key on
every route.