path_template URL-encodes slashes in model name, breaking ai.run() in v5
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 65/100
Direzione di ricerca
Inizia in cloudflare._utils.path_template e segui il punto di ingresso client.ai.run utilizzando il nome del modello della riproduzione. Verifica il percorso generato rispetto al percorso del modello non suddiviso previsto, quindi aggiungi o aggiorna una copertura mirata affinché gli identificatori del modello contenenti slash producano la route prevista senza compromettere i parametri ordinari.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Confirm this is a Python library issue and not an underlying Cloudflare API issue.
- This is an issue with the Python library
Describe the bug
Bug: path_template URL-encodes slashes in model name, breaking ai.run() in v5
Description
After upgrading from cloudflare Python SDK v4.3.1 to v5.x, my calls to client.ai.run() fail with a 400 error:
{
"success": false,
"errors": [{"code": 7000, "message": "No route for that URI"}],
"messages": [],
"result": null
}
The root cause seems to be that path_template() URL-encodes the forward slashes (/ → %2F) in the model_name parameter, producing an invalid API path.
Expected path
/accounts/{account_id}/ai/run/@cf/black-forest-labs/flux-1-schnell
Actual path (v5)
/accounts/{account_id}/ai/run/@cf%2Fblack-forest-labs%2Fflux-1-schnell
Reproduction
from cloudflare import Cloudflare
client = Cloudflare(api_token="<valid_token>")
# This worked in v4.3.1, fails in v5 with "No route for that URI"
result = client.ai.run(
"@cf/black-forest-labs/flux-1-schnell",
account_id="<account_id>",
prompt="a cat sitting on a chair",
)
I also confirmed the encoding without making an API call:
from cloudflare._utils import path_template
path = path_template(
"/accounts/{account_id}/ai/run/{model_name}",
account_id="test123",
model_name="@cf/black-forest-labs/flux-1-schnell",
)
print(path)
# Output: /accounts/test123/ai/run/@cf%2Fblack-forest-labs%2Fflux-1-schnell
# Expected: /accounts/test123/ai/run/@cf/black-forest-labs/flux-1-schnell
Environment
- SDK version: 5.0.0 / 5.1.0 (both affected)
- Python: 3.12
- OS: Ubuntu 24 (GitHub Actions runner) — also reproducible locally
- Last working version: 4.3.1
Impact
This breaks every client.ai.run() call for any model which identifiers contain slashes (e.g. @cf/meta/llama-3.1-8b-instruct, @cf/black-forest-labs/flux-1-schnell, etc.).
Workaround
In the meantime, I am using a workaround based on the REST API directly to bypass the SDK:
import requests
response = requests.post(
f"https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run/@cf/black-forest-labs/flux-1-schnell",
headers={"Authorization": f"Bearer {api_token}"},
json={"prompt": "a cat sitting on a chair"},
)
data = response.json()
To Reproduce
from cloudflare import Cloudflare
client = Cloudflare(api_token="<valid_token>")
# This worked in v4.3.1, fails in v5 with "No route for that URI"
result = client.ai.run(
"@cf/black-forest-labs/flux-1-schnell",
account_id="<account_id>",
prompt="a cat sitting on a chair",
)
Code snippets
OS
Linux Fedora
Python version
3.12
Library version
5.1.0
- Lingua principale
- Python
- Stelle
- 509
- Fork
- 150
- Merge medio
- 3h 15m
- PR unite (30g)
- 1
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di cloudflare/cloudflare-python
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
cloudflare/cloudflare-python#2747 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
cloudflare/cloudflare-python#2692 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
cloudflare/cloudflare-python#2679 · 4 commenti · 5 reazioni ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
cloudflare/cloudflare-python#2745 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
cloudflare/cloudflare-python#2742 ·
Tutte le issue di cloudflare/cloudflare-python
Issue simili
-
area: harness bug status: needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Human-Agent-Society/reef#625 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
learningequality/kolibri#15351 · 2 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Name consistency Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
eellak/triplestore#65 · 1 commento ·