Repository navigation
Raise ImageUploadError from Project.upload() when the API answers a string error - #586
tonylampada wants to merge 2 commits into
Conversation
rfapi.upload_image read the message of a non-200 answer with
error.get("message"), which assumes "error" is an object. The API also
answers {"error": "<text>"}, for example a 503 from an instance that is
shutting down. That raised AttributeError, which the upload retry does
not catch, so num_retry_uploads never retried it.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
TrailThis change was planned and built by Claude, and reviewed twice by a second model (Codex): once on the plan before any code, once on the diff before this PR opened. Plan Reviews
No finding in either review, so there is no answer to record. Notes taken from the plan review (none changed the plan)
Notes taken from the diff review
Seen next to the fix and left out
Plan review, round 1Plan gate reviewNo Critical or Warning findings. The plan addresses the shared cause in EvidenceRead Ran a mocked HTTP reproduction with the installed worktree The existing nested-error test checks compatibility with Notes
verdict: go Diff review, round 1Diff gate reviewReviewed FindingsNone. No Critical, Warning, or Minor findings. Review
Validation
Notes
verdict: go |
Description
Anyone uploading images with the SDK or
roboflow image upload, on the released 1.7.3, getsAttributeError: 'str' object has no attribute 'get'when the upload fails and the API answers{"error": "<text>"}.By the API's code, errors thrown inside the upload handler (403, 404, 409, 500) and the 503 of an instance that is shutting down answer the string shape. A missing or invalid API key does not: production answers those with the object shape, which the SDK already handles. The upload retry catches
ImageUploadErroronly, sonum_retry_uploadsnever retried the string answers. Found by reading the code; no user report.What changes:
Project.upload()andsingle_upload()raiseImageUploadErrorwith the API's text andstatus_code.num_retry_uploadsset, the SDK retries that upload.roboflow image upload <file>printsError: Instance recycling. The exit code is still 1.upload_dataset()androboflow image upload <folder>print[ERR] <path> (Instance recycling)for that image and go on, as before.Tested
tests/test_project.pypass on 4cfa25d and fail with the adapter frommain.make check_code_qualityclean.roboflow image uploadon a file and on a folder against mocked HTTP, before and after.roboflowrepo, not from a captured response.Evidence
All runs on 4cfa25d, from the repo root, after
uv venv .venv --python 3.12 && uv pip install --python .venv/bin/python -e ".[dev]". No network.The two new tests
The same tests with the adapter from the base (9415946). Tracebacks cut to their last frame.
Suite and lint. mypy's
annotation-uncheckednotes cut.The CLI. Save as
cli-proof.pyand run.venv/bin/python - < cli-proof.py.On 4cfa25d (progress bar cut):
With the adapter from 9415946 (progress bar cut):
What production answers without a valid key (2026-11-24, no key needed). Both are the object shape, not the string shape this PR handles.
Deploy
None. It ships with the next PyPI release.
Your calls
Project.upload_image.Reviewer guide
None: small fix.
🤖 Generated with Claude Code