Version check on the import path makes `--version` and `--help` do network I/O
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- cli, networking
Direzione di ricerca
Start with lightning_sdk/init.py:59-60 to trace the import-time check, then read lightning_sdk/helpers.py:25, 48, and 60 for caching, requests, and exception handling. Decide where the check should run and verify that --help, --version, and offline commands no longer perform network I/O or traceback with an invalid certificate path.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What happens
lightning --version and lightning --help reach out to PyPI over the network. Neither command
needs to. A PyPI version check runs while the package is being imported, which happens before the
CLI ever looks at the arguments it was given.
flowchart LR
A["lightning --version"] --> B[import lightning_sdk]
B --> C["version check<br/>calls pypi.org"]
C --> D[CLI parses the arguments]
D --> E[prints the version]
C -.->|"slow, unreachable<br/>or misconfigured TLS"| F[hangs or fails<br/>before D]
Three consequences, all reproducible today:
- An offline-looking command can fail. With
REQUESTS_CA_BUNDLEorSSL_CERT_FILEpointing at
a path that does not exist,requestsraises a plainOSError, the version check only catches
requests.exceptions.RequestException, and the error escapes — so--versionand--helpboth
traceback. (A bundle that exists but cannot be read is fine; that arrives asSSLError, which is
caught.) - Any command can stall. The request has no timeout, so a slow or unresponsive
pypi.org
holds up whatever the user typed, for as long as it takes. - Every invocation pays for it. The result is cached on the checker instance, which lives and
dies with the process, so there is no reuse between commands. An agent or script running 40
lightningcommands makes 40 PyPI requests. Library users pay it too: anyimport lightning_sdk
in a notebook, a training script or a service's startup path makes the same call.
Repro
$ REQUESTS_CA_BUNDLE=/tmp/does-not-exist.txt lightning --version
...
File ".../requests/adapters.py", line 332, in cert_verify
raise OSError(
OSError: Could not find a suitable TLS CA certificate bundle, invalid path: /tmp/does-not-exist.txt
Verified on lightning-sdk==2026.9.15, macOS, Python 3.14. The same command succeeds with
LIGHTNING_DISABLE_VERSION_CHECK=1, which confirms where the failure comes from.
For consequence 3, any lightning --version shows an outbound connection to pypi.org:443.
Where it comes from
lightning_sdk/__init__.py:59-60runs the check at module scope, so importing the package
performs network I/O.lightning_sdk/helpers.py:48makes the request with no timeout.lightning_sdk/helpers.py:60catches onlyrequests.exceptions.RequestException.lightning_sdk/helpers.py:25holds the cache per instance, and the instance is per process.
Why it matters
A version check is advisory. It should never be able to break --help, and it should not be on the
critical path of commands that do not talk to the platform. The failure is also hard to place from
the outside: users see a TLS or network error from a command they expect to be local, and the
message says nothing about a version check. Agent sandboxes make this more likely, since they
routinely redirect or restrict certificate paths.
Suggested direction
Smallest first, and the first one is worth doing on its own:
- Give the request a timeout, and catch
OSErrorrather thanRequestException(the latter is a
subclass of the former, so this widens the net without losing anything). - Move the check off the import path. Run it when a command is already talking to the platform, or
after the command's work is done, so--version,--helpand every offline command cost nothing. - Cache the answer on disk with a TTL, so it is at most one request per day per machine instead of
one per process.
Happy to take this on if the direction looks right. (2) is the real fix and the one that needs a
decision on where the check should live; (1) is a couple of lines and could land immediately.
- Lingua principale
- Python
- Stelle
- 13
- Fork
- 4
- Merge medio
- 1g 2h
- PR unite (30g)
- 40
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi 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 Lightning-AI/sdk
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Lightning-AI/sdk#259 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
Lightning-AI/sdk#152 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
Lightning-AI/sdk#132 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Lightning-AI/sdk
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
openfoodfacts/openfoodfacts-python#573 ·
I maintainer di solito rispondono entro 2 giorni
-
Rasterio reads over HTTPS do not send the Earthdata token and return 500 "HTTP response code: 404"Apertacredentials rasterio
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
developmentseed/titiler-cmr#359 ·
I maintainer di solito rispondono entro 1 giorno
-
Claiming namespace `r33net`Apertanamespace team:operations
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
EclipseFdn/open-vsx.org#16444 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
EbookFoundation/free-programming-books#13696 ·
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
ossf/oss-crs#548 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno