Skip to content

Commit

Permalink
[Fix] Extracted file content not found (#1062)
Browse files Browse the repository at this point in the history
fixed extract not found  issue
  • Loading branch information
jagadeeswaran-zipstack authored Jan 10, 2025
1 parent b69ec16 commit 06fb3b7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions backend/file_management/file_management_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,6 @@ def fetch_file_contents(
raise ConnectorApiRequestError

data = ""
# Check if the file type is in the allowed list
if file_content_type not in allowed_content_types:
raise InvalidFileType(f"File type '{file_content_type}' is not allowed.")

# Handle allowed file types
if file_content_type == "application/pdf":
Expand All @@ -191,6 +188,10 @@ def fetch_file_contents(
logger.info(f"Reading text file: {file_path}")
data = file.read()

# Check if the file type is in the allowed list
elif file_content_type not in allowed_content_types:
raise InvalidFileType(f"File type '{file_content_type}' is not allowed.")

else:
logger.warning(f"File type '{file_content_type}' is not handled.")

Expand Down
4 changes: 3 additions & 1 deletion backend/prompt_studio/prompt_studio_core_v2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,9 @@ def fetch_contents_ide(self, request: HttpRequest, pk: Any = None) -> Response:
if not file_path.endswith("/"):
file_path += "/"
file_path += file_name
contents = FileManagerHelper.fetch_file_contents(file_system, file_path)
contents = FileManagerHelper.fetch_file_contents(
file_system, file_path, allowed_content_types
)
else:
try:
contents = PromptStudioFileHelper.fetch_file_contents(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ function DocumentManager({ generateIndex, handleUpdateTool, handleDocChange }) {
throw new Error("Fail to load the file");
};
} else if (viewType === viewTypes.extract) {
setExtractTxt(data);
setExtractTxt(data?.data);
}
};

Expand Down

0 comments on commit 06fb3b7

Please sign in to comment.