@devries-cameron20 / composio-1 / commits / b1c6671b2
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.

fix(py): send Content-Type on S3 PUTs and parse Content-Length (#4168)

This PR: - fixes #4153 - supersedes https://github.com/ComposioHQ/composio/pull/4154 (fork PR authored against a pre-#4146 tree; its tests patch `requests.put`, which `upload()` no longer calls after #4146, so they fail on merge) - adds `parse_content_length()` in `composio.utils.url_safety`, shared by both URL fetch helpers (`_files.py::_fetch_file_from_url` and `tool_router_session_files.py::_fetch_url_bytes`), so a malformed/negative remote `Content-Length` degrades to unknown size under the streamed byte count instead of raising a raw `ValueError` - converges the file and bytes upload paths onto `_upload_to_presigned_url()`: one PUT that sends the `Content-Type` the presign request was signed with and raises `ErrorUploadingFile` carrying the HTTP status (a 403 no longer collapses into a path-only error) - single-sources the presign wire shape via `_request_presigned_upload()`; `from_path()` forwards the exact mimetype it minted, so signed and sent content types cannot drift - mirrors the TypeScript SDK: `uploadFileToS3` funnels path/URL/File inputs through one uploader that always sends `Content-Type` and throws on non-2xx, and `readResponseBodyWithLimit` trusts `Content-Length` only as a hint - adds tests against the `safe_request` seam (`test_file_upload_robustness.py`, plus one malformed-header case for `RemoteFile.buffer()`) ## Context Both defects in #4153 were symptoms of two parallel upload paths drifting: the bytes path sent `Content-Type` and raised with the status, the file path did neither. Patching the symptom in place (as #4154 proposed) would have left three presigned PUT sites and two error contracts in the tree; this PR deletes the drift vector instead. Full suite green (1320 passed), `make chk` and `make snt` clean; Python-only change, so no changeset per `AGENTS.md`. --------- Co-authored-by: Mustaqeem66 <265153888+Mustaqeem66@users.noreply.github.com>

Alberto Schiabel committed Aug 18, 2026 at 19:09 UTC b1c6671b205a50f1ba4ad74ea102301d914befb1
6 files changed +383 -77
python/composio/core/models/_files.py
+109 -72
@@ -1,7 +1,6 @@
1 from __future__ import annotations
2
3 import hashlib
4 -import logging
4 import os
5 import typing as t
6 from pathlib import Path
@@ -27,7 +26,11 @@ from composio.exceptions import (
26 from composio.utils import mimetypes
27 from composio.utils.json_schema import dereference_json_schema
28 from composio.utils.safe_path import secure_basename_join, secure_join
30 -from composio.utils.url_safety import assert_safe_fetch_target, safe_request
29 +from composio.utils.url_safety import (
30 + assert_safe_fetch_target,
31 + parse_content_length,
32 + safe_request,
33 +)
34 from composio.utils.sensitive_file_upload_paths import (
35 assert_safe_local_file_upload_path,
36 )
@@ -55,8 +58,6 @@ Maximum response size in bytes when fetching files from URLs.
58 Prevents memory exhaustion attacks from malicious URLs pointing to large files.
59 """
60
58 -_logger = logging.getLogger(__name__)
59 -
61 _CONNECT_TIMEOUT = 5 # seconds
62 _READ_TIMEOUT = 60 # seconds
63 """
@@ -191,32 +192,67 @@ def get_md5(file: Path) -> str:
192 return obj.hexdigest()
193
194
194 -def upload(url: str, file: Path) -> bool:
195 +def _upload_to_presigned_url(
196 + url: str, data: t.Union[bytes, t.IO[bytes]], mimetype: str
197 +) -> None:
198 + """PUT ``data`` to a presigned S3 URL with the content type it was signed with.
199 +
200 + The presign request carries ``mimetype``, so the PUT must send the same
201 + value as ``Content-Type``: when the signature covers the content type, a
202 + mismatched or missing header is rejected with ``403 SignatureDoesNotMatch``.
203 + Routing every presigned PUT through one helper keeps the file and bytes
204 + upload paths from drifting apart again, mirroring ``uploadFileToS3`` in
205 + the TypeScript SDK, which funnels path, URL, and File inputs through a
206 + single uploader.
207 +
208 + Raises:
209 + ErrorUploadingFile: On transport failure or a non-200 response,
210 + including the HTTP status when one was received.
211 + """
212 + try:
213 + response = safe_request(
214 + "PUT",
215 + url,
216 + data=data,
217 + headers={"Content-Type": mimetype},
218 + timeout=(_CONNECT_TIMEOUT, _READ_TIMEOUT),
219 + )
220 + except requests.exceptions.RequestException as e:
221 + raise ErrorUploadingFile(
222 + "Failed to upload to S3: "
223 + f"{_sanitize_url_for_logging(url)}. Error: {type(e).__name__}"
224 + ) from e
225 + if response.status_code != 200:
226 + raise ErrorUploadingFile(
227 + f"Failed to upload to S3. Status: {response.status_code}. "
228 + "This may indicate an expired presigned URL or permission issue."
229 + )
230 +
231 +
232 +def upload(url: str, file: Path, mimetype: t.Optional[str] = None) -> bool:
233 """Upload file to presigned S3 URL.
234
235 Args:
236 url: Presigned S3 upload URL
237 file: Path to file to upload
238 + mimetype: Content type to send with the upload. Defaults to the type
239 + guessed from ``file``. This must match the ``mimetype`` the
240 + presigned URL was requested with, otherwise S3 rejects the PUT
241 + with ``403 SignatureDoesNotMatch`` when the signature covers the
242 + content type.
243
244 Returns:
202 - True if upload succeeded (HTTP 200), False otherwise
245 + True if the upload succeeded.
246 +
247 + Raises:
248 + ErrorUploadingFile: If the upload fails; the message includes the
249 + HTTP status when one was received.
250 """
251 + if mimetype is None:
252 + mimetype = mimetypes.guess(file=file)
253 with file.open("rb") as data:
205 - try:
206 - response = safe_request(
207 - "PUT",
208 - url,
209 - data=data,
210 - timeout=(_CONNECT_TIMEOUT, _READ_TIMEOUT),
211 - )
212 - except requests.exceptions.RequestException as e:
213 - _logger.debug(
214 - "Upload to %s failed: %s",
215 - _sanitize_url_for_logging(url),
216 - type(e).__name__,
217 - )
218 - return False
219 - return response.status_code == 200
254 + _upload_to_presigned_url(url=url, data=data, mimetype=mimetype)
255 + return True
256
257
258 class _FileUploadResponse(_ComposioBaseModel):
@@ -226,6 +262,33 @@ class _FileUploadResponse(_ComposioBaseModel):
262 new_presigned_url: str
263
264
265 +def _request_presigned_upload(
266 + client: HttpClient,
267 + *,
268 + filename: str,
269 + md5: str,
270 + mimetype: str,
271 + tool: str,
272 + toolkit: str,
273 +) -> _FileUploadResponse:
274 + """Request a presigned S3 upload URL from the backend.
275 +
276 + Single-sources the presign wire shape so the file and bytes upload paths
277 + request the same fields they later send.
278 + """
279 + return client.post(
280 + path=_FILE_UPLOAD,
281 + body={
282 + "md5": md5,
283 + "filename": filename,
284 + "mimetype": mimetype,
285 + "tool_slug": tool,
286 + "toolkit_slug": toolkit,
287 + },
288 + cast_to=_FileUploadResponse,
289 + )
290 +
291 +
292 def _is_url(value: str) -> bool:
293 """Check if a string is a valid HTTP/HTTPS URL."""
294 try:
@@ -371,12 +434,15 @@ def _fetch_file_from_url(
434 f"Status: {response.status_code}"
435 )
436
374 - # Check Content-Length header first (early abort for oversized files)
375 - content_length = response.headers.get("Content-Length")
376 - if content_length and int(content_length) > max_size:
437 + # Check Content-Length header first (early abort for oversized files).
438 + # The header is a hint from the remote server: `parse_content_length`
439 + # returns None for anything untrustworthy, and the streaming guard below
440 + # is the authoritative limit.
441 + content_length = parse_content_length(response.headers.get("Content-Length"))
442 + if content_length is not None and content_length > max_size:
443 response.close()
444 raise ResponseTooLargeError(
379 - f"File size ({int(content_length)} bytes) exceeds maximum allowed "
445 + f"File size ({content_length} bytes) exceeds maximum allowed "
446 f"size ({max_size} bytes)"
447 )
448
@@ -435,42 +501,17 @@ def _upload_bytes_to_s3(
501 toolkit: str,
502 ) -> str:
503 """Upload bytes content to S3 and return the S3 key."""
438 - md5_hash = hashlib.md5(content, usedforsecurity=False).hexdigest()
439 -
440 - s3meta = client.post(
441 - path=_FILE_UPLOAD,
442 - body={
443 - "md5": md5_hash,
444 - "filename": filename,
445 - "mimetype": mimetype,
446 - "tool_slug": tool,
447 - "toolkit_slug": toolkit,
448 - },
449 - cast_to=_FileUploadResponse,
504 + s3meta = _request_presigned_upload(
505 + client,
506 + filename=filename,
507 + md5=hashlib.md5(content, usedforsecurity=False).hexdigest(),
508 + mimetype=mimetype,
509 + tool=tool,
510 + toolkit=toolkit,
511 + )
512 + _upload_to_presigned_url(
513 + url=s3meta.new_presigned_url, data=content, mimetype=mimetype
514 )
451 -
452 - # Upload the content directly to S3
453 - try:
454 - upload_response = safe_request(
455 - "PUT",
456 - s3meta.new_presigned_url,
457 - data=content,
458 - headers={"Content-Type": mimetype},
459 - timeout=(_CONNECT_TIMEOUT, _READ_TIMEOUT),
460 - )
461 - except requests.exceptions.RequestException as e:
462 - raise ErrorUploadingFile(
463 - "Failed to upload to S3: "
464 - f"{_sanitize_url_for_logging(s3meta.new_presigned_url)}. "
465 - f"Error: {type(e).__name__}"
466 - ) from e
467 -
468 - if upload_response.status_code != 200:
469 - raise ErrorUploadingFile(
470 - f"Failed to upload to S3. Status: {upload_response.status_code}. "
471 - f"This may indicate an expired presigned URL or permission issue."
472 - )
473 -
515 return s3meta.key
516
517
@@ -611,19 +652,15 @@ class FileUploadable(BaseModel):
652 )
653
654 mimetype = mimetypes.guess(file=file)
614 - s3meta = client.post(
615 - path=_FILE_UPLOAD,
616 - body={
617 - "md5": get_md5(file=file),
618 - "filename": file.name,
619 - "mimetype": mimetype,
620 - "tool_slug": tool,
621 - "toolkit_slug": toolkit,
622 - },
623 - cast_to=_FileUploadResponse,
655 + s3meta = _request_presigned_upload(
656 + client,
657 + filename=file.name,
658 + md5=get_md5(file=file),
659 + mimetype=mimetype,
660 + tool=tool,
661 + toolkit=toolkit,
662 )
625 - if not upload(url=s3meta.new_presigned_url, file=file):
626 - raise ErrorUploadingFile(f"Error uploading file: {file}")
663 + upload(url=s3meta.new_presigned_url, file=file, mimetype=mimetype)
664 return cls(name=file.name, mimetype=mimetype, s3key=s3meta.key)
665
666
python/composio/core/models/tool_router_session_files.py
+8 -4
@@ -29,7 +29,11 @@ from composio.exceptions import (
29 )
30 from composio.utils.mimetypes import get_extension_from_mime_type
31 from composio.utils.safe_path import secure_basename_join
32 -from composio.utils.url_safety import assert_safe_fetch_target, safe_request
32 +from composio.utils.url_safety import (
33 + assert_safe_fetch_target,
34 + parse_content_length,
35 + safe_request,
36 +)
37 from composio.utils.uuid import generate_short_id
38
39 DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID = "files"
@@ -107,12 +111,12 @@ def _fetch_url_bytes(url: str) -> t.Tuple[bytes, str]:
111 status_code=response.status_code, status_text=response.reason
112 )
113
110 - content_length = response.headers.get("Content-Length")
111 - if content_length and int(content_length) > _MAX_RESPONSE_SIZE:
114 + content_length = parse_content_length(response.headers.get("Content-Length"))
115 + if content_length is not None and content_length > _MAX_RESPONSE_SIZE:
116 response.close()
117 raise _UrlFetchError(
118 size_detail=(
115 - f"File size ({int(content_length)} bytes) exceeds maximum allowed "
119 + f"File size ({content_length} bytes) exceeds maximum allowed "
120 f"size ({_MAX_RESPONSE_SIZE} bytes)"
121 )
122 )
python/composio/utils/url_safety.py
+26
@@ -15,6 +15,11 @@ pass this check and still connect to the private address. Closing that window
15 requires pinning the validated address and connecting to it directly (a custom
16 ``requests`` transport adapter), which is out of scope for this module; the
17 TypeScript guard carries the same limitation.
18 +
19 +Also parses response headers that gate how much of a body the SDK reads:
20 +``parse_content_length`` treats ``Content-Length`` as the untrusted hint it
21 +is, so a malformed value degrades to an unknown size under a streamed byte
22 +count instead of crashing the fetch.
23 """
24
25 from __future__ import annotations
@@ -91,6 +96,27 @@ def assert_safe_fetch_target(url: str) -> None:
96 )
97
98
99 +def parse_content_length(value: t.Optional[str]) -> t.Optional[int]:
100 + """Parse a ``Content-Length`` header into a non-negative ``int``.
101 +
102 + ``Content-Length`` is supplied by the remote server and is therefore
103 + untrusted: it may be absent, non-numeric (``"abc"``), fractional
104 + (``"12.5"``), thousands-separated (``"1,024"``) or negative. Anything
105 + untrustworthy returns ``None`` so the caller treats the size as unknown
106 + and falls through to a streamed byte count, which stays authoritative
107 + because the header can also be absent or understated. Mirrors
108 + ``readResponseBodyWithLimit`` in the TypeScript SDK, which only trusts
109 + values matching ``/^\\d+$/``.
110 + """
111 + if value is None:
112 + return None
113 + try:
114 + size = int(value.strip())
115 + except ValueError:
116 + return None
117 + return size if size >= 0 else None
118 +
119 +
120 def safe_request(
121 method: str,
122 url: str,
python/tests/test_file_upload_robustness.py new
+221
@@ -0,0 +1,221 @@
1 +"""Regression tests for file upload and URL fetch robustness.
2 +
3 +Covers https://github.com/ComposioHQ/composio/issues/4153: a malformed
4 +``Content-Length`` response header must not crash the URL fetch helpers with
5 +a raw ``ValueError``, and the local-file presigned PUT must send the
6 +``Content-Type`` it was signed with. The shared helpers under test keep the
7 +fetch and upload paths from drifting apart again.
8 +"""
9 +
10 +import typing as t
11 +from pathlib import Path
12 +from unittest.mock import MagicMock, patch
13 +
14 +import pytest
15 +import requests
16 +
17 +from composio.core.models._files import (
18 + FileUploadable,
19 + _fetch_file_from_url,
20 + upload,
21 +)
22 +from composio.core.models.base import allow_tracking
23 +from composio.exceptions import ErrorUploadingFile, ResponseTooLargeError
24 +from composio.utils import mimetypes
25 +from composio.utils.url_safety import parse_content_length
26 +
27 +
28 +@pytest.fixture(autouse=True)
29 +def disable_telemetry():
30 + """Disable telemetry for all tests to prevent thread issues."""
31 + token = allow_tracking.set(False)
32 + yield
33 + allow_tracking.reset(token)
34 +
35 +
36 +def _stream_response(
37 + headers: t.Dict[str, str],
38 + chunks: t.Optional[t.List[bytes]] = None,
39 +) -> MagicMock:
40 + """A streaming `requests` response double, as `_fetch_file_from_url` reads it."""
41 + response = MagicMock()
42 + response.ok = True
43 + response.status_code = 200
44 + response.headers = headers
45 + response.iter_content.return_value = chunks if chunks is not None else [b"payload"]
46 + response.close = MagicMock()
47 + return response
48 +
49 +
50 +def _s3_client(presigned_url: str = "https://s3.example.com/upload") -> MagicMock:
51 + """A mock HTTP client whose presign POST answers a fresh upload URL."""
52 + client = MagicMock()
53 + s3meta = MagicMock()
54 + s3meta.key = "s3-key-123"
55 + s3meta.new_presigned_url = presigned_url
56 + client.post.return_value = s3meta
57 + return client
58 +
59 +
60 +class TestPresignedUploadContentType:
61 + """The PUT must send the content type the presigned URL was signed with."""
62 +
63 + @patch("composio.core.models._files.safe_request")
64 + def test_upload_sends_explicit_mimetype(
65 + self, mock_safe_request: MagicMock, tmp_path: Path
66 + ):
67 + mock_safe_request.return_value = MagicMock(status_code=200)
68 + source = tmp_path / "report.pdf"
69 + source.write_bytes(b"%PDF-1.4")
70 +
71 + assert upload(
72 + url="https://s3.example.com/upload",
73 + file=source,
74 + mimetype="application/pdf",
75 + )
76 +
77 + assert mock_safe_request.call_args.args == (
78 + "PUT",
79 + "https://s3.example.com/upload",
80 + )
81 + assert mock_safe_request.call_args.kwargs["headers"] == {
82 + "Content-Type": "application/pdf"
83 + }
84 + assert mock_safe_request.call_args.kwargs["timeout"] == (5, 60)
85 +
86 + @patch("composio.core.models._files.safe_request")
87 + def test_upload_guesses_mimetype_when_omitted(
88 + self, mock_safe_request: MagicMock, tmp_path: Path
89 + ):
90 + """Back-compat: two-argument callers still send a Content-Type."""
91 + mock_safe_request.return_value = MagicMock(status_code=200)
92 + source = tmp_path / "notes.txt"
93 + source.write_text("hello")
94 +
95 + assert upload(url="https://s3.example.com/upload", file=source)
96 +
97 + assert mock_safe_request.call_args.kwargs["headers"] == {
98 + "Content-Type": mimetypes.guess(file=source)
99 + }
100 +
101 + @patch("composio.core.models._files.safe_request")
102 + def test_from_path_put_matches_presigned_mimetype(
103 + self, mock_safe_request: MagicMock, tmp_path: Path
104 + ):
105 + """The PUT content type must match the mimetype used to mint the URL.
106 +
107 + S3 answers ``403 SignatureDoesNotMatch`` when a presigned URL is
108 + signed over a content type the subsequent PUT does not send, which
109 + made the local-file path fail where the bytes path succeeded.
110 + """
111 + mock_safe_request.return_value = MagicMock(status_code=200)
112 + client = _s3_client()
113 + source = tmp_path / "photo.jpg"
114 + source.write_bytes(b"jpeg bytes")
115 +
116 + result = FileUploadable.from_path(
117 + client=client,
118 + file=source,
119 + tool="TEST_TOOL",
120 + toolkit="test_toolkit",
121 + )
122 +
123 + presigned_mimetype = client.post.call_args.kwargs["body"]["mimetype"]
124 + assert presigned_mimetype == mimetypes.guess(file=source)
125 + assert mock_safe_request.call_args.kwargs["headers"] == {
126 + "Content-Type": presigned_mimetype
127 + }
128 + assert result.mimetype == presigned_mimetype
129 + assert result.s3key == "s3-key-123"
130 +
131 + @patch("composio.core.models._files.safe_request")
132 + def test_upload_surfaces_http_status(
133 + self, mock_safe_request: MagicMock, tmp_path: Path
134 + ):
135 + """A rejected PUT raises with the status instead of returning False."""
136 + mock_safe_request.return_value = MagicMock(status_code=403)
137 + source = tmp_path / "report.pdf"
138 + source.write_bytes(b"%PDF-1.4")
139 +
140 + with pytest.raises(ErrorUploadingFile, match="403"):
141 + upload(url="https://s3.example.com/upload", file=source)
142 +
143 + @patch("composio.core.models._files.safe_request")
144 + def test_upload_wraps_transport_errors_without_leaking_the_url(
145 + self, mock_safe_request: MagicMock, tmp_path: Path
146 + ):
147 + mock_safe_request.side_effect = requests.exceptions.Timeout(
148 + "HTTPSConnectionPool(host='s3.example.com', port=443): "
149 + "Max retries exceeded with url: /upload?token=abc"
150 + )
151 + source = tmp_path / "report.pdf"
152 + source.write_bytes(b"%PDF-1.4")
153 +
154 + with pytest.raises(ErrorUploadingFile) as exc_info:
155 + upload(url="https://s3.example.com/upload?token=abc", file=source)
156 +
157 + assert "Failed to upload to S3" in str(exc_info.value)
158 + assert "token=abc" not in str(exc_info.value)
159 +
160 +
161 +class TestParseContentLength:
162 + """``Content-Length`` is remote-controlled input and must not crash a fetch."""
163 +
164 + @pytest.mark.parametrize(
165 + "value, expected",
166 + [
167 + ("0", 0),
168 + ("1024", 1024),
169 + (" 2048 ", 2048),
170 + ],
171 + )
172 + def test_accepts_valid_sizes(self, value: str, expected: int):
173 + assert parse_content_length(value) == expected
174 +
175 + @pytest.mark.parametrize(
176 + "value",
177 + [None, "", " ", "abc", "12.5", "1,024", "1e3", "0x10", "100 200", "-1"],
178 + )
179 + def test_untrustworthy_values_mean_unknown_size(self, value: t.Optional[str]):
180 + assert parse_content_length(value) is None
181 +
182 +
183 +class TestMalformedContentLength:
184 + """A malformed header degrades to unknown size under the streaming cap."""
185 +
186 + @pytest.mark.parametrize(
187 + "header", ["abc", "12.5", "1,024", "1e3", "0x10", "100 200", ""]
188 + )
189 + @patch("composio.core.models._files.assert_safe_fetch_target")
190 + @patch("composio.core.models._files.requests.get")
191 + def test_malformed_header_does_not_raise(
192 + self, mock_get: MagicMock, _mock_assert: MagicMock, header: str
193 + ):
194 + """A malformed header must not surface a raw ValueError to the caller."""
195 + mock_get.return_value = _stream_response(
196 + {"content-type": "image/jpeg", "Content-Length": header}
197 + )
198 +
199 + filename, content, mimetype = _fetch_file_from_url(
200 + "https://example.com/image.jpg"
201 + )
202 +
203 + assert filename == "image.jpg"
204 + assert content == b"payload"
205 + assert mimetype == "image/jpeg"
206 +
207 + @patch("composio.core.models._files.assert_safe_fetch_target")
208 + @patch("composio.core.models._files.requests.get")
209 + def test_negative_header_still_enforced_while_streaming(
210 + self, mock_get: MagicMock, _mock_assert: MagicMock
211 + ):
212 + """A negative header means unknown size, not a trusted "small" value."""
213 + mock_get.return_value = _stream_response(
214 + {"Content-Length": "-1"},
215 + [b"x" * 1024 * 1024 for _ in range(20)],
216 + )
217 +
218 + with pytest.raises(ResponseTooLargeError):
219 + _fetch_file_from_url(
220 + "https://example.com/large.zip", max_size=10 * 1024 * 1024
221 + )
python/tests/test_tool_router_session_files.py
+18
@@ -376,6 +376,24 @@ class TestResponseDerivedUrlsAreGuarded:
376
377 assert mock_get.call_args.kwargs["allow_redirects"] is False
378
379 + def test_buffer_tolerates_malformed_content_length(self):
380 + """A malformed `Content-Length` means unknown size, not a crash.
381 +
382 + The header is remote-controlled; `_fetch_url_bytes` must fall through
383 + to the streamed byte count instead of raising `ValueError` out of
384 + `int()` (the crash class issue #4153 fixed for `_files.py`).
385 + """
386 + rf = self._remote_file("https://s3.example.com/download")
387 + malformed = mock_stream_response()
388 + malformed.headers = {
389 + "content-type": "text/plain",
390 + "Content-Length": "1,024",
391 + }
392 +
393 + with patch(ASSERT_SAFE_FETCH_TARGET):
394 + with patch("requests.get", return_value=malformed):
395 + assert rf.buffer() == b"file content"
396 +
397 def test_buffer_caps_response_size(self):
398 """The body is streamed against a cap rather than read whole."""
399 rf = self._remote_file("https://s3.example.com/download")
python/tests/test_upload_dir_allowlist.py
+1 -1
@@ -239,7 +239,7 @@ class TestFileUploadableAllowlistWiring:
239 mock_client.post.return_value = Mock(
240 new_presigned_url="https://example/upload", key="k"
241 )
242 - monkeypatch.setattr(files_mod, "upload", lambda url, file: True)
242 + monkeypatch.setattr(files_mod, "upload", lambda url, file, mimetype=None: True)
243
244 result = FileUploadable.from_path(
245 client=mock_client,