PathLike upload tuples fail with an opaque connection error

Aperta
#196 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
api

Direzione di ricerca

Start with is_file_content() and _transform_file(), which handle the shared upload path for certificate, extension, and session uploads. Run the existing upload tests and add sync and async coverage for PathLike values in the supported tuple shapes. Done means tuple uploads read the path while preserving the custom filename, content type, and optional headers.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What happened?

A bare Path works as an upload, but the tuple form accepted by FileTypes does not:

from pathlib import Path

client.sessions.uploads.create(
    "session-id",
    file=("custom.md", Path("README.md"), "text/markdown"),
)

On current main at 5f5274b, this raises:

APIConnectionError: Connection error.

The underlying cause is:

AttributeError: 'PosixPath' object has no attribute 'read'

The same path is shared by certificate, extension, and session uploads.

Why it happens

is_file_content() treats every tuple as terminal file content. That means _transform_file() returns the tuple unchanged before its tuple-handling branch can read the PathLike value inside it. HTTPX later receives the raw Path and tries to call .read() on it.

Expected behavior

A PathLike inside any supported upload tuple should be read just like a bare Path, while preserving the custom filename, content type, and optional headers.

I have a small fix ready that keeps tuples separate from direct file content and adds sync and async coverage for all three supported tuple shapes.

Lingua principale
Python
Stelle
93
Fork
16
Merge medio
11m
PR unite (30g)
3

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di browserbase/sdk-python

Tutte le issue di browserbase/sdk-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.