fix(types): narrow combo credential preflight (#10254)

This commit is contained in:
backryun
2026-08-14 12:57:43 +09:00
committed by GitHub
parent 876cc42089
commit 4eac410c94
3 changed files with 10 additions and 1 deletions

View File

@@ -787,7 +787,7 @@ async function handleChatImplementation(
...(bypassProviderQuotaPolicy ? { bypassQuotaPolicy: true } : {}),
}
);
if (!creds || creds.allRateLimited) return false;
if (!creds || !("authType" in creds)) return false;
// OAuth selection must happen atomically with occupancy reservation in the
// actual dispatch. Availability preflight may finish well before a combo

View File

@@ -654,6 +654,7 @@ type AnonymousFallbackProviderDefinition = {
noAuth?: boolean;
};
function buildSyntheticNoAuthCredentials(providerSpecificData: JsonRecord = {}): {
authType: "none";
apiKey: null;
accessToken: null;
refreshToken: null;
@@ -676,6 +677,7 @@ function buildSyntheticNoAuthCredentials(providerSpecificData: JsonRecord = {}):
retryAfterHuman?: never;
} {
return {
authType: "none",
apiKey: null,
accessToken: null,
refreshToken: null,

View File

@@ -117,6 +117,13 @@ test("extractApiKey parses bearer headers and isValidApiKey validates persisted
assert.equal(await auth.isValidApiKey(""), false);
});
test("getProviderCredentials identifies synthetic no-auth credentials", async () => {
const credentials = await auth.getProviderCredentials("opencode");
assert.equal(credentials?.connectionId, "noauth");
assert.equal(credentials?.authType, "none");
});
test("getProviderCredentials reports rate limiting when only inactive suppressed records remain", async () => {
const retryAfter = futureIso();
await seedConnection("openai", {