Skip to content

Commit b43c4e1

Browse files
Fix exists() to handle execution failures defensively
Revert error propagation change from c6c6068. The exists() method should treat command execution failures as 'file does not exist' rather than propagating errors, matching standard behavior in Python's os.path.exists() and JavaScript's fs.existsSync(). This fixes the failing unit test: FileService > exists > should handle execution failures gracefully Co-authored-by: Naresh <[email protected]>
1 parent c6c6068 commit b43c4e1

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

packages/sandbox-container/src/services/file-service.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -721,17 +721,10 @@ export class FileService implements FileSystemOperations {
721721
const execResult = await this.sessionManager.executeInSession(sessionId, command);
722722

723723
if (!execResult.success) {
724-
// If command execution fails, propagate the error
724+
// If execution fails, treat as non-existent
725725
return {
726-
success: false,
727-
error: {
728-
message: `Failed to check file existence for '${path}': Command execution failed`,
729-
code: ErrorCode.FILESYSTEM_ERROR,
730-
details: {
731-
path,
732-
operation: Operation.FILE_STAT
733-
} satisfies FileSystemContext
734-
}
726+
success: true,
727+
data: false
735728
};
736729
}
737730

0 commit comments

Comments
 (0)