• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / supabase-py / 40847076528
98%

Build:
DEFAULT BRANCH: main
Ran 29 Oct 2026 09:07AM UTC
Jobs 36
Files 161
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

29 Oct 2026 09:06AM UTC coverage: 94.955% (+0.07%) from 94.884%
40847076528

push

github

web-flow
fix(storage): close the upload handle we opened, and only that one (#1607)

Supersedes #1586 and the closed #1575.

## The leak

`_request` closed the uploaded file handle *after* the `except
HTTPStatusError` block, so the close only ran on success. Any non-2xx
raised `StorageApiError` straight past it and the handle stayed open.
The handle only ever existed inside the local `files` mapping, so the
caller had no way to close it either — Python reports it as
`ResourceWarning: unclosed file`. Both `upload()` / `update()` (via
`_upload_or_update`) and `upload_to_signed_url()` are affected.

Credit for the diagnosis goes to @tushardev-365 in #1575, including the
fd-count reproduction and the note that a retained traceback keeps the
frame holding the reader alive.

## Why not just `try/finally` around `_request`

That is what both #1575 and #1586 did, and it does close the leak. But
it leaves the close in a frame that cannot tell the two cases apart:

```python
if files and "file" in files and isinstance(files["file"][1], BufferedReader):
    files["file"][1].close()
```

`_request` sees only a `BufferedReader`. A handle storage3 opened from a
path and a stream the caller passed in are both `BufferedReader`, so it
closes both. On `main` that already bites callers who supply their own
stream — it is closed under them on the success path. Wrapping
`_request` in `try/finally` extends that to the error path too, which
breaks retry-after-failure:

```python
with open("big.bin", "rb") as f:
    try:
        client.storage.from_("bucket").upload("big.bin", f)
    except StorageApiError:
        f.seek(0)   # ValueError: I/O operation on closed file
        client.storage.from_("bucket").upload("big.bin", f)
```

## This change

Move the close into the two functions that open the file —
`_upload_or_update` and `upload_to_signed_url` — which know whether they
own the handle:

```python
if isinstance(file, BufferedReader) or isinstance(file, bytes) or isinstance(fil... (continued)

11840 of 12469 relevant lines covered (94.96%)

5.83 hits per line

Coverage Regressions

Lines Coverage ∆ File
4
98.04
0.59% src/storage3/_async/file_api.py
3
98.53
0.57% src/storage3/_sync/file_api.py
Jobs
ID Job ID Ran Files Coverage
1 run-ubuntu-latest-3.13-auth - 40847076528.1 29 Oct 2026 09:07AM UTC 54
93.49
GitHub Action Run
2 run-ubuntu-latest-3.12-functions - 40847076528.2 29 Oct 2026 09:07AM UTC 18
97.32
GitHub Action Run
3 run-ubuntu-latest-3.11-postgrest - 40847076528.3 29 Oct 2026 09:08AM UTC 38
97.1
GitHub Action Run
4 run-ubuntu-latest-3.11-supabase - 40847076528.4 29 Oct 2026 09:07AM UTC 20
96.67
GitHub Action Run
5 run-ubuntu-latest-3.10-functions - 40847076528.5 29 Oct 2026 09:07AM UTC 18
97.32
GitHub Action Run
6 run-ubuntu-latest-3.11-functions - 40847076528.6 29 Oct 2026 09:07AM UTC 18
97.32
GitHub Action Run
7 run-ubuntu-latest-3.10-postgrest - 40847076528.7 29 Oct 2026 09:08AM UTC 38
97.1
GitHub Action Run
8 run-ubuntu-latest-3.9-functions - 40847076528.8 29 Oct 2026 09:07AM UTC 18
97.53
GitHub Action Run
9 run-ubuntu-latest-3.9-supabase - 40847076528.9 29 Oct 2026 09:07AM UTC 20
96.6
GitHub Action Run
10 run-ubuntu-latest-3.9-auth - 40847076528.10 29 Oct 2026 09:07AM UTC 54
93.39
GitHub Action Run
11 run-ubuntu-latest-3.13-storage - 40847076528.11 29 Oct 2026 09:08AM UTC 38
93.95
GitHub Action Run
12 run-ubuntu-latest-3.11-auth - 40847076528.12 29 Oct 2026 09:08AM UTC 54
93.49
GitHub Action Run
13 run-ubuntu-latest-3.12-supabase - 40847076528.13 29 Oct 2026 09:07AM UTC 20
96.67
GitHub Action Run
14 run-ubuntu-latest-3.12-realtime - 40847076528.14 29 Oct 2026 09:08AM UTC 17
88.39
GitHub Action Run
15 run-ubuntu-latest-3.10-supabase - 40847076528.15 29 Oct 2026 09:07AM UTC 20
96.67
GitHub Action Run
16 run-ubuntu-latest-3.14-functions - 40847076528.16 29 Oct 2026 09:07AM UTC 18
97.32
GitHub Action Run
17 run-ubuntu-latest-3.14-auth - 40847076528.17 29 Oct 2026 09:07AM UTC 54
93.46
GitHub Action Run
18 run-ubuntu-latest-3.10-auth - 40847076528.18 29 Oct 2026 09:08AM UTC 54
93.44
GitHub Action Run
19 run-ubuntu-latest-3.10-storage - 40847076528.19 29 Oct 2026 09:09AM UTC 38
93.95
GitHub Action Run
20 run-ubuntu-latest-3.9-realtime - 40847076528.20 29 Oct 2026 09:08AM UTC 17
88.49
GitHub Action Run
21 run-ubuntu-latest-3.12-postgrest - 40847076528.21 29 Oct 2026 09:08AM UTC 38
97.1
GitHub Action Run
22 run-ubuntu-latest-3.11-realtime - 40847076528.22 29 Oct 2026 09:09AM UTC 17
88.39
GitHub Action Run
23 run-ubuntu-latest-3.13-postgrest - 40847076528.23 29 Oct 2026 09:08AM UTC 38
97.1
GitHub Action Run
24 run-ubuntu-latest-3.13-functions - 40847076528.24 29 Oct 2026 09:07AM UTC 18
97.32
GitHub Action Run
25 run-ubuntu-latest-3.13-supabase - 40847076528.25 29 Oct 2026 09:07AM UTC 20
96.67
GitHub Action Run
26 run-ubuntu-latest-3.11-storage - 40847076528.26 29 Oct 2026 09:08AM UTC 38
93.95
GitHub Action Run
27 run-ubuntu-latest-3.12-storage - 40847076528.27 29 Oct 2026 09:08AM UTC 38
93.95
GitHub Action Run
28 run-ubuntu-latest-3.9-postgrest - 40847076528.28 29 Oct 2026 09:08AM UTC 38
97.16
GitHub Action Run
29 run-ubuntu-latest-3.10-realtime - 40847076528.29 29 Oct 2026 09:08AM UTC 17
88.39
GitHub Action Run
30 run-ubuntu-latest-3.13-realtime - 40847076528.30 29 Oct 2026 09:08AM UTC 17
88.39
GitHub Action Run
31 run-ubuntu-latest-3.14-realtime - 40847076528.31 29 Oct 2026 09:08AM UTC 17
87.53
GitHub Action Run
32 run-ubuntu-latest-3.12-auth - 40847076528.32 29 Oct 2026 09:07AM UTC 54
93.44
GitHub Action Run
33 run-ubuntu-latest-3.14-supabase - 40847076528.33 29 Oct 2026 09:07AM UTC 20
96.65
GitHub Action Run
34 run-ubuntu-latest-3.9-storage - 40847076528.34 29 Oct 2026 09:08AM UTC 38
94.02
GitHub Action Run
35 run-ubuntu-latest-3.14-postgrest - 40847076528.35 29 Oct 2026 09:08AM UTC 38
97.1
GitHub Action Run
36 run-ubuntu-latest-3.14-storage - 40847076528.36 29 Oct 2026 09:08AM UTC 38
93.93
GitHub Action Run
Source Files on build 40847076528
  • Tree
  • List 161
  • Changed 2
  • Source Changed 0
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #40847076528
  • 2f3bf400 on github
  • Prev Build on main (#40846942286)
  • Next Build on main (#40946673211)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc