fix(client): accept image URLs in image_edit #6008
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.43) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 360 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.352
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #6008"
general
weight: 0.35
Jackmeson1
What happens
Both
image_editdocstrings accept image URLs, but both clients treat URL strings as local filenames. On Windows this raisesOSErrorbefore uploading anything.Downloading the URL also needs a read timeout: a host can send headers and the first body byte, then stop sending data.
Cause
The edit route expects uploaded file content. The clients previously opened string inputs as local paths, and the initial URL-download implementation supplied no connect/read timeout.
Change
Download HTTP(S) URLs for single images, list entries and optional masks before constructing the multipart upload. Preserve the existing handling of local paths, bytes and file objects.
Use a 10-second connect and 30-second read timeout for downloads, matching the server's image-fetch defaults. Async downloads also retain the session total. The edit upload retains its existing timeout behavior: no timeout in the sync client, and the session timeout, normally 1800 seconds, in the async client.
HTTP and transport download failures raise
RuntimeErrorwith the original exception as the cause, before any edit upload. Async responses are released on failure and success. The existingimage_editdocstrings already document URL inputs andRuntimeError.Downloads do not pass the handle's Authorization header. Bodies are buffered in memory. The read timeout limits inactivity rather than total duration; it does not impose an overall deadline on synchronous DNS resolution, redirects or a steadily arriving response. No public timeout parameter is added.
Tests
On Windows, with
PYTHONPATH=., Python 3.14.6 and 3.10.20, aiohttp 3.14.5, requests 2.34.2 and pytest 9.1.1:I ran
483b6a62: 81 passed on each Python, including all 16 image cases. The eight timeout cases fail against f5b09322 because downloads lack explicit bounds or wait for the stalled server to close.Coverage includes URL images and masks, mixed lists, local-input controls, omitted download Authorization, HTTP failures, stalled response bodies, preserved async session totals and unchanged edit-upload timeout settings. The additional exception assertions check
RuntimeErrorand its original cause.On Ubuntu 24.04.5 with Python 3.12.3 (Transformers 5.x and the CI pin 4.57.6) and 3.10.22, the 16 image cases passed, and the 71 client tests that use these helpers passed. Changed-file pre-commit, including
xinference/types.py, passed.AI disclosure: this was prepared with AI assistance (Claude Opus 5.5 and Claude Sonnet 5.5).
🤖 Generated with Claude Code
https://claude.ai/code/session_01JfvcPZyKcKQUG9fQGYfRMw