Skip to content

Fix: Validate empty file paths in file processing #1592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dipampaul17
Copy link

@dipampaul17 dipampaul17 commented May 12, 2025

Fix: Validate empty file paths in file processing

Problem

When empty file paths are provided in actions like GMAIL_SEND_EMAIL, the application throws cryptic ENOENT errors instead of providing clear validation messages. This creates a poor developer experience and makes debugging difficult.

Solution

This PR adds proper validation for empty file paths at three critical points in the codebase:

  1. In readFileContent function (fileUtils.ts):
if (!path || path.trim() === '') {
  throw new Error('File path cannot be empty');
}
In getFileDataAfterUploadingToS3 function (fileUtils.ts):
typescript
CopyInsert
if (!path || path.trim() === '') {
  throw new Error('File path cannot be empty');
}
In processFileUpload function (file.ts):
typescript
CopyInsert
const filePath = value as string;
if (!filePath || filePath.trim() === '') {
  throw new Error('File path cannot be empty');
}

These validations ensure that empty or whitespace-only file paths are caught early with clear error messages, preventing the cryptic ENOENT errors that would occur when attempting to read empty file paths.

Testing
End-to-end testing has been performed using the project's testing framework. All tests pass successfully, confirming that:

Empty paths are properly validated and throw the expected error
Whitespace-only paths are properly detected
The validation occurs at all critical points in the file processing workflow
Related Issue
Fixes #1578

@utkarsh-dixit

- Add validation for empty file paths in readFileContent function
- Add validation for empty file paths in getFileDataAfterUploadingToS3 function
- Add validation for empty file paths in processFileUpload function
- Improve error messages for better debugging
- Prevent ENOENT errors when empty paths are provided in actions like GMAIL_SEND_EMAIL

This change ensures proper validation of file paths before attempting to access the file system,
providing clear error messages instead of cryptic ENOENT errors when empty paths are provided.
Copy link

vercel bot commented May 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
composio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 12, 2025 4:04am

@dipampaul17 dipampaul17 changed the title Fix empty file path validation Fix: Validate empty file paths in file processing May 12, 2025
Copy link

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant