mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-26 03:07:00 -07:00
fix(core): ensure stable fallback for restricted preview models (#26999)
This commit is contained in:
@@ -77,6 +77,7 @@ const createMockConfig = (overrides: Partial<Config> = {}): Config =>
|
||||
getModel: vi.fn(() => MOCK_PRO_MODEL),
|
||||
getUserTier: vi.fn(() => undefined),
|
||||
isInteractive: vi.fn(() => false),
|
||||
getHasAccessToPreviewModel: vi.fn(() => false),
|
||||
...overrides,
|
||||
}) as unknown as Config;
|
||||
|
||||
@@ -234,6 +235,7 @@ describe('handleFallback', () => {
|
||||
vi.mocked(policyConfig.getModel).mockReturnValue(
|
||||
PREVIEW_GEMINI_MODEL_AUTO,
|
||||
);
|
||||
vi.mocked(policyConfig.getHasAccessToPreviewModel).mockReturnValue(true);
|
||||
|
||||
const result = await handleFallback(
|
||||
policyConfig,
|
||||
|
||||
@@ -20,6 +20,8 @@ import {
|
||||
applyAvailabilityTransition,
|
||||
} from '../availability/policyHelpers.js';
|
||||
|
||||
import { isPreviewModel } from '../config/models.js';
|
||||
|
||||
export const UPGRADE_URL_PAGE = 'https://goo.gle/set-up-gemini-code-assist';
|
||||
|
||||
export async function handleFallback(
|
||||
@@ -28,13 +30,19 @@ export async function handleFallback(
|
||||
authType?: string,
|
||||
error?: unknown,
|
||||
): Promise<string | boolean | null> {
|
||||
const failureKind = classifyFailureKind(error);
|
||||
|
||||
// If a preview model is not found, record that the user lacks preview access.
|
||||
if (failureKind === 'not_found' && isPreviewModel(failedModel, config)) {
|
||||
config.setHasAccessToPreviewModel?.(false);
|
||||
}
|
||||
|
||||
const chain = resolvePolicyChain(config);
|
||||
const { failedPolicy, candidates } = buildFallbackPolicyContext(
|
||||
chain,
|
||||
failedModel,
|
||||
);
|
||||
|
||||
const failureKind = classifyFailureKind(error);
|
||||
const availability = config.getModelAvailabilityService();
|
||||
const getAvailabilityContext = () => {
|
||||
if (!failedPolicy) return undefined;
|
||||
|
||||
Reference in New Issue
Block a user