fix(core): use debug level for keychain fallback logging (#25398)

This commit is contained in:
Emily Hedlund
2026-04-14 11:33:01 -07:00
committed by GitHub
parent 02792264ed
commit 88ddcab616
2 changed files with 14 additions and 11 deletions

View File

@@ -53,7 +53,7 @@ vi.mock('../utils/events.js', () => ({
}));
vi.mock('../utils/debugLogger.js', () => ({
debugLogger: { log: vi.fn() },
debugLogger: { debug: vi.fn() },
}));
vi.mock('node:os', async (importOriginal) => {
@@ -153,14 +153,14 @@ describe('KeychainService', () => {
// Because it falls back to FileKeychain, it is always available.
expect(available).toBe(true);
expect(debugLogger.log).toHaveBeenCalledWith(
expect(debugLogger.debug).toHaveBeenCalledWith(
expect.stringContaining('encountered an error'),
'locked',
);
expect(coreEvents.emitTelemetryKeychainAvailability).toHaveBeenCalledWith(
expect.objectContaining({ available: false }),
);
expect(debugLogger.log).toHaveBeenCalledWith(
expect(debugLogger.debug).toHaveBeenCalledWith(
expect.stringContaining('Using FileKeychain fallback'),
);
expect(FileKeychain).toHaveBeenCalled();
@@ -173,7 +173,7 @@ describe('KeychainService', () => {
const available = await service.isAvailable();
expect(available).toBe(true);
expect(debugLogger.log).toHaveBeenCalledWith(
expect(debugLogger.debug).toHaveBeenCalledWith(
expect.stringContaining('failed structural validation'),
expect.objectContaining({ getPassword: expect.any(Array) }),
);
@@ -191,7 +191,7 @@ describe('KeychainService', () => {
const available = await service.isAvailable();
expect(available).toBe(true);
expect(debugLogger.log).toHaveBeenCalledWith(
expect(debugLogger.debug).toHaveBeenCalledWith(
expect.stringContaining('functional verification failed'),
);
expect(FileKeychain).toHaveBeenCalled();
@@ -243,7 +243,7 @@ describe('KeychainService', () => {
);
expect(mockKeytar.setPassword).not.toHaveBeenCalled();
expect(FileKeychain).toHaveBeenCalled();
expect(debugLogger.log).toHaveBeenCalledWith(
expect(debugLogger.debug).toHaveBeenCalledWith(
expect.stringContaining('MacOS default keychain not found'),
);
});

View File

@@ -114,7 +114,7 @@ export class KeychainService {
}
// If native failed or was skipped, return the secure file fallback.
debugLogger.log('Using FileKeychain fallback for secure storage.');
debugLogger.debug('Using FileKeychain fallback for secure storage.');
return new FileKeychain();
}
@@ -130,7 +130,7 @@ export class KeychainService {
// Probing macOS prevents process-blocking popups when no keychain exists.
if (os.platform() === 'darwin' && !this.isMacOSKeychainAvailable()) {
debugLogger.log(
debugLogger.debug(
'MacOS default keychain not found; skipping functional verification.',
);
return null;
@@ -140,12 +140,15 @@ export class KeychainService {
return keychainModule;
}
debugLogger.log('Keychain functional verification failed');
debugLogger.debug('Keychain functional verification failed');
return null;
} catch (error) {
// Avoid logging full error objects to prevent PII exposure.
const message = error instanceof Error ? error.message : String(error);
debugLogger.log('Keychain initialization encountered an error:', message);
debugLogger.debug(
'Keychain initialization encountered an error:',
message,
);
return null;
}
}
@@ -162,7 +165,7 @@ export class KeychainService {
return potential as Keychain;
}
debugLogger.log(
debugLogger.debug(
'Keychain module failed structural validation:',
result.error.flatten().fieldErrors,
);