@devries-cameron20 / composio Mirror · read-only / commits / 4b230ee46
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 13:15 UTC

fix: preserve original filename when appending extension from mimetype

Fixes issue where filenames without extensions were replaced with timestamped names. Now a URL like https://example.com/invoice with mimetype application/pdf becomes invoice.pdf instead of file_20260126_abc12345.pdf.

jkomyno committed Jan 27, 2026 at 03:57 UTC 4b230ee46f15781fc54eb221aabaad390a40461b
2 files changed +5 -5
python/composio/core/models/_files.py
+1 -1
@@ -163,7 +163,7 @@ def _fetch_file_from_url(url: str) -> t.Tuple[str, bytes, str]:
163 # If filename has no extension, try to add one from mimetype
164 if "." not in filename:
165 extension = _get_extension_from_mimetype(mimetype)
166 - filename = _generate_timestamped_filename(extension)
166 + filename = f"{filename}{extension}"
167
168 return filename, content, mimetype
169
python/tests/test_files.py
+4 -4
@@ -1075,8 +1075,8 @@ class TestFetchFileFromUrl:
1075 assert filename.endswith(".png")
1076
1077 @patch("composio.core.models._files.requests.get")
1078 - def test_fetch_file_from_url_generates_filename_when_no_extension(self, mock_get):
1079 - """Test filename generation when URL filename has no extension."""
1078 + def test_fetch_file_from_url_appends_extension_when_missing(self, mock_get):
1079 + """Test extension is appended to original filename when missing."""
1080 mock_response = MagicMock()
1081 mock_response.ok = True
1082 mock_response.content = b"pdf data"
@@ -1087,8 +1087,8 @@ class TestFetchFileFromUrl:
1087 "https://example.com/document"
1088 )
1089
1090 - assert filename.startswith("file_")
1091 - assert filename.endswith(".pdf")
1090 + # Should preserve original filename and append extension
1091 + assert filename == "document.pdf"
1092
1093 @patch("composio.core.models._files.requests.get")
1094 def test_fetch_file_from_url_failure(self, mock_get):