From 258c6715dc07c55bd352c911c414bb03cee2b4be Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 15 May 2026 10:46:43 +0000 Subject: [PATCH] Refactor sanitizeValue to use unknown instead of any Replaced `any` with `unknown` type in `sanitizeValue` method of `LoggingDatabaseOperations` to improve type safety and comply with codebase rules. Added strict type guards and safely checked `byteLength` on unknown objects to satisfy the TypeScript compiler. --- src/loggingDatabaseOperations.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/loggingDatabaseOperations.ts b/src/loggingDatabaseOperations.ts index 3819711..a0fec99 100644 --- a/src/loggingDatabaseOperations.ts +++ b/src/loggingDatabaseOperations.ts @@ -33,7 +33,7 @@ export class LoggingDatabaseOperations implements DatabaseOperations { return this.wrapped.engineKind; } - private sanitizeValue(value: any): string { + private sanitizeValue(value: unknown): string { if (value === null) return 'null'; if (value === undefined) return 'undefined'; if (typeof value === 'string') { @@ -42,8 +42,13 @@ export class LoggingDatabaseOperations implements DatabaseOperations { } return `"${value}"`; } - if (value instanceof Uint8Array || (typeof value === 'object' && value && 'buffer' in value)) { - return `[BLOB ${value.byteLength} bytes]`; + if (value instanceof Uint8Array || (typeof value === 'object' && value !== null && 'buffer' in value)) { + const byteLength = value instanceof Uint8Array + ? value.byteLength + : ('byteLength' in value && typeof (value as { byteLength: unknown }).byteLength === 'number' + ? (value as { byteLength: number }).byteLength + : 0); + return `[BLOB ${byteLength} bytes]`; } if (typeof value === 'object') { try {