Skip to content

Commit 5266abb

Browse files
committed
made file_mount limits more restrictive
1 parent cccf210 commit 5266abb

2 files changed

Lines changed: 19 additions & 26 deletions

File tree

src/runloop_api_client/_constants.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
MAX_RETRY_DELAY = 60.0
1515

1616
# Maximum allowed size (in bytes) for individual entries in `file_mounts` when creating Blueprints
17-
FILE_MOUNT_MAX_SIZE_BYTES = 512 * 1024
17+
# NOTE: Capped at ~786,000 bytes to align with the approximate macOS maximum
18+
# shell command length when embedding base64-encoded content. Since base64 is
19+
# ASCII, bytes ≈ characters here, and we measure size using UTF-8 encoding.
20+
FILE_MOUNT_MAX_SIZE_BYTES = 786_000
1821

1922
# Maximum allowed total size (in bytes) across all `file_mounts` when creating Blueprints
20-
FILE_MOUNT_TOTAL_MAX_SIZE_BYTES = 1024 * 1024
23+
FILE_MOUNT_TOTAL_MAX_SIZE_BYTES = 786_000 * 10 # ~10 mb

tests/api_resources/test_blueprints.py

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ def test_streaming_response_create(self, client: Runloop) -> None:
110110

111111
@parametrize
112112
def test_create_rejects_large_file_mount(self, client: Runloop) -> None:
113-
# 512KB + 1 byte
114-
too_large_content = "a" * (512 * 1024 + 1)
113+
# 786,000 bytes + 1 byte
114+
too_large_content = "a" * (786_000 + 1)
115115
with pytest.raises(ValueError, match=r"over the limit"):
116116
client.blueprints.create(
117117
name="name",
@@ -120,19 +120,14 @@ def test_create_rejects_large_file_mount(self, client: Runloop) -> None:
120120

121121
@parametrize
122122
def test_create_rejects_total_file_mount_size(self, client: Runloop) -> None:
123-
# Two files at exactly per-file max, plus 1 extra byte across a third file to exceed 1MB total
124-
per_file_max = 512 * 1024
125-
content_a = "a" * per_file_max
126-
content_b = "b" * per_file_max
127-
content_c = "c" * 1
123+
# Ten files at exactly per-file max, plus 1 extra byte to exceed total limit
124+
per_file_max = 786_000
125+
file_mounts = {f"/tmp/{i}.txt": "a" * per_file_max for i in range(10)}
126+
file_mounts["/tmp/extra.txt"] = "x"
128127
with pytest.raises(ValueError, match=r"total file_mounts size .* over the limit"):
129128
client.blueprints.create(
130129
name="name",
131-
file_mounts={
132-
"/tmp/a.txt": content_a,
133-
"/tmp/b.txt": content_b,
134-
"/tmp/c.txt": content_c,
135-
},
130+
file_mounts=file_mounts,
136131
)
137132

138133
@parametrize
@@ -565,8 +560,8 @@ async def test_streaming_response_create(self, async_client: AsyncRunloop) -> No
565560

566561
@parametrize
567562
async def test_create_rejects_large_file_mount(self, async_client: AsyncRunloop) -> None:
568-
# 512KB + 1 byte
569-
too_large_content = "a" * (512 * 1024 + 1)
563+
# 786,000 bytes + 1 byte
564+
too_large_content = "a" * (786_000 + 1)
570565
with pytest.raises(ValueError, match=r"over the limit"):
571566
await async_client.blueprints.create(
572567
name="name",
@@ -575,19 +570,14 @@ async def test_create_rejects_large_file_mount(self, async_client: AsyncRunloop)
575570

576571
@parametrize
577572
async def test_create_rejects_total_file_mount_size(self, async_client: AsyncRunloop) -> None:
578-
# Two files at exactly per-file max, plus 1 extra byte across a third file to exceed 1MB total
579-
per_file_max = 512 * 1024
580-
content_a = "a" * per_file_max
581-
content_b = "b" * per_file_max
582-
content_c = "c" * 1
573+
# Ten files at exactly per-file max, plus 1 extra byte to exceed total limit
574+
per_file_max = 786_000
575+
file_mounts = {f"/tmp/{i}.txt": "a" * per_file_max for i in range(10)}
576+
file_mounts["/tmp/extra.txt"] = "x"
583577
with pytest.raises(ValueError, match=r"total file_mounts size .* over the limit"):
584578
await async_client.blueprints.create(
585579
name="name",
586-
file_mounts={
587-
"/tmp/a.txt": content_a,
588-
"/tmp/b.txt": content_b,
589-
"/tmp/c.txt": content_c,
590-
},
580+
file_mounts=file_mounts,
591581
)
592582

593583
@parametrize

0 commit comments

Comments
 (0)