← Back to Pull requests

fix(client): accept image URLs in image_edit #6008

Closed
unknown closed this pull request without merging on Nov 04, 2026 16:07 UTC
View on GitHub
unknown unknown commented on Nov 04, 2026 01:42 UTC
Author

What happens

Both image_edit docstrings accept image URLs, but both clients treat URL strings as local filenames. On Windows this raises OSError before 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 RuntimeError with the original exception as the cause, before any edit upload. Async responses are released on failure and success. The existing image_edit docstrings already document URL inputs and RuntimeError.

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:

python -m pytest -q -p no:cacheprovider -o addopts="" xinference/client/tests --ignore=xinference/client/tests/test_client.py --ignore=xinference/client/tests/test_async_client.py

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 RuntimeError and 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

Diff: 360 lines (+270 / -90) across 4 files Reviewer: Jackmeson1 Review duration: 865m
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
0.43
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
56%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 56.8% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 42.6% (MEDIUM) · Higher = larger blast radius
42.6%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 56.8% · Lower = rushed or shallow review
56.8%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 18.4% · Safe to merge
18.4%