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 21, 07:15 UTC
fix(py): keep the extension of files fetched from extensionless URLs (#5119)
This PR: - Closes #5105 - makes `_get_extension_from_mimetype` in `python/composio/core/models/_files.py` look types up in the shared `composio.utils.mimetypes` table (the one behind `get_extension_from_mime_type`, ported from the TypeScript `getExtensionFromMimeType`) and deletes the private 20-entry copy - an export URL such as `.../export?format=xlsx` now uploads as `file_<ts>_<id>.xlsx`; docx, pptx, xls, doc, ppt, csv, tar, mov, and ogg are covered too - keeps the empty extension for `application/octet-stream` and unknown types: the shared helper's subtype fallback is not used on this path, so no invented extensions - adds `text/csv` → `csv` to the Python table and both TypeScript tables (`mime.ts`, `fileUtils.node.ts`) so they stay identical; TypeScript already returned `csv` through its subtype fallback, so its output is unchanged (patch changeset for `@composio/core`/`@composio/slim` per repo convention) - @yunusarda-sudo posted a fix on their fork (https://github.com/yunusarda-sudo/composio/tree/fix/url-download-mimetype-extension), which also added `text/csv` to both SDKs; this PR takes a smaller table-only lookup instead of their fallback chain, so their code is not reused Verification (from `python/`, `composio.__file__` checked to be this checkout): - new `test_files.py` cases against the old code: 11 failed, 5 passed; with the fix all pass - `pytest tests/test_files.py tests/test_mimetypes.py tests/test_tool_router_session_files.py`: 292 passed - `ruff check` and `ruff format --check` (`config/ruff.toml`) clean on touched files; `mypy==2.3.1 --config-file config/mypy.ini composio/` and on `tests/test_files.py`: no issues - `ts/packages/core`: `vitest run test/utils` 375 passed; Prettier clean; `pnpm validate:changesets` passed