mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-24 03:54:43 -07:00
fix(core): handle optional response fields from code assist API (#20345)
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
type CodeAssistServer,
|
||||
UserTierId,
|
||||
getCodeAssistServer,
|
||||
debugLogger,
|
||||
} from '@google/gemini-cli-core';
|
||||
|
||||
export interface PrivacyState {
|
||||
@@ -103,7 +104,12 @@ async function getRemoteDataCollectionOptIn(
|
||||
): Promise<boolean> {
|
||||
try {
|
||||
const resp = await server.getCodeAssistGlobalUserSetting();
|
||||
return resp.freeTierDataCollectionOptin;
|
||||
if (resp.freeTierDataCollectionOptin === undefined) {
|
||||
debugLogger.warn(
|
||||
'Warning: Code Assist API did not return freeTierDataCollectionOptin. Defaulting to true.',
|
||||
);
|
||||
}
|
||||
return resp.freeTierDataCollectionOptin ?? true;
|
||||
} catch (error: unknown) {
|
||||
if (error && typeof error === 'object' && 'response' in error) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
@@ -128,5 +134,10 @@ async function setRemoteDataCollectionOptIn(
|
||||
cloudaicompanionProject: server.projectId,
|
||||
freeTierDataCollectionOptin: optIn,
|
||||
});
|
||||
return resp.freeTierDataCollectionOptin;
|
||||
if (resp.freeTierDataCollectionOptin === undefined) {
|
||||
debugLogger.warn(
|
||||
`Warning: Code Assist API did not return freeTierDataCollectionOptin. Defaulting to ${optIn}.`,
|
||||
);
|
||||
}
|
||||
return resp.freeTierDataCollectionOptin ?? optIn;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user