Repository navigation
fix(transport): stop retrying certificate failures and name the fix (#461) - #463
Draft
thodson-usgs wants to merge 1 commit into
Draft
thodson-usgs wants to merge 1 commit into
thodson-usgs wants to merge 1 commit into
Conversation
…OI-USGS#461) A server certificate that Python does not trust, usually because a network proxy or firewall re-signs HTTPS with an organization root that certifi does not contain, was classed as transient. The fan-out getters spent their retry budget on it and raised ServiceInterrupted, telling the caller to resume once the service recovered. ssl.SSLCertVerificationError is now a deterministic failure, so it is neither retried nor resumable, and network_error() appends a remedy: verify against the operating system's certificates with truststore, or set SSL_CERT_FILE to a bundle containing the organization's root certificate. No dependency is added. A NetworkError from an unchunked OGC query also names the request URL instead of "unknown service".
thodson-usgs
force-pushed
the
fix/ssl-error-message
branch
from
November 4, 2026 17:56
51564b2 to
0bc2d30
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #461.
Problem
When a network proxy or firewall re-signs HTTPS traffic (common on agency and corporate networks), Python rejects the server certificate with
CERTIFICATE_VERIFY_FAILED. Before this change:ServiceInterrupted, which tells the caller to resume once the service recovers.nwis,wqp) raised a bareNetworkErrorthat gave no remedy.Could not reach the service at unknown service.Fix
The message gives two ways to trust the root certificate that the interception proxy uses:
pip install truststore, thenimport truststore; truststore.inject_into_ssl()before the first request. This verifies against the operating system's trust store, where IT installs the organization root. truststore's docs sayinject_into_ssl()is for applications and scripts, not libraries, so the library only suggests it to the user and never calls it.SSL_CERT_FILEto a PEM bundle that contains the organization's root certificate.No dependency is added.
What changed
interruptions._deterministic_failuretreatsssl.SSLCertVerificationErroras deterministic, so it is neither retried nor offered as resumable. A new_certificate_rejected()predicate sits next to it, andtransport.http.network_error()uses that predicate to append the remedy. One predicate decides both behaviors, so they can't drift apart.FanOut._normalize_failurefalls back to the failed request's URL when the plan has nocanonical_url.userguide/errors.rst, and a NEWS entry.Verification
tests/transport_test.pycover: not retried and not resumable, exactly one attempt, the remedy text, no remedy on other connection failures, and the URL fallback.SSL_CERT_FILEat a self-signed bundle.waterdata.get_dailyandwqp.what_sitesnow raiseNetworkErroron the first attempt and name the real URL. In a scratch venv (not added to the project), I made certifi's bundle invalid and confirmed thattruststore.inject_into_ssl()alone makesget_dailysucceed.Known gap (follow-up)
NetworkError.retryableis a class-levelTrue. A caller that branches one.retryable, as the errors guide suggests, will still retry a certificate failure. Permanent DNS failures already behave this way. Fixing it would mean a per-instanceretryableor a new subclass, which changes the public exception taxonomy, so I left it out of this PR.