From f5e0f16157da6a0b0dbae3b4ebf920fdee81c461 Mon Sep 17 00:00:00 2001 From: Akhil Appana Date: Fri, 8 Aug 2025 04:33:42 -0700 Subject: fix: properly report tool errors in telemetry (#5688) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- packages/core/src/utils/fileUtils.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'packages/core/src/utils') diff --git a/packages/core/src/utils/fileUtils.ts b/packages/core/src/utils/fileUtils.ts index 30ab69c6..92186e4f 100644 --- a/packages/core/src/utils/fileUtils.ts +++ b/packages/core/src/utils/fileUtils.ts @@ -195,10 +195,18 @@ export async function detectFileType( return 'text'; } +export enum FileErrorType { + FILE_NOT_FOUND = 'FILE_NOT_FOUND', + IS_DIRECTORY = 'IS_DIRECTORY', + FILE_TOO_LARGE = 'FILE_TOO_LARGE', + READ_ERROR = 'READ_ERROR', +} + export interface ProcessedFileReadResult { llmContent: PartUnion; // string for text, Part for image/pdf/unreadable binary returnDisplay: string; error?: string; // Optional error message for the LLM if file processing failed + errorType?: FileErrorType; // Structured error type using enum isTruncated?: boolean; // For text files, indicates if content was truncated originalLineCount?: number; // For text files linesShown?: [number, number]; // For text files [startLine, endLine] (1-based for display) @@ -225,6 +233,7 @@ export async function processSingleFileContent( llmContent: '', returnDisplay: 'File not found.', error: `File not found: ${filePath}`, + errorType: FileErrorType.FILE_NOT_FOUND, }; } const stats = await fs.promises.stat(filePath); @@ -233,6 +242,7 @@ export async function processSingleFileContent( llmContent: '', returnDisplay: 'Path is a directory.', error: `Path is a directory, not a file: ${filePath}`, + errorType: FileErrorType.IS_DIRECTORY, }; } -- cgit v1.2.3