fix(sparql): fallback GET anche su timeout/rete + errore GET 5xx - #448
Merged
Conversation
… GET 5xx Completa il fix #447 (POST 403 → GET fallback) con i casi che il docstring prometteva ma il codice non copriva: - POST con errore di rete/timeout (post_status None) → prova GET fallback - GET fallback che restituisce 5xx → DownloadError esplicito con status Test: 4 casi coperti (403→GET, timeout→GET, GET 500→errore, POST 500→errore). 26/26 pass, mypy ok, ruff ok. End-to-end sul Senato reale: OK.
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.
Sintesi
Completa il fix SPARQL del POST 403 (#447) con i casi che il docstring prometteva ma il codice non copriva: timeout/errore di rete e GET fallback con 5xx.
Contesto collegato
senato-ddl(dataset-incubator #781): il POST al Senato può fallire con errore di rete (non solo 403), e in quel caso il GET fallback non scattavaCosa cambia
Impatto su contratti pubblici
Nessuno — comportamento interno del fetch.
Dettaglio
Prima (gap del #447):
post_status is None) →raise DownloadError("POST → unknown")senza provare il GET — nonostante il docstring dicesse "Se POST fallisce (403, timeout), prova GET"Dopo:
post_status is None)DownloadError("SPARQL GET fallback returned HTTP {status}")esplicitoVerifica
Verifica end-to-end sul Senato reale:
SparqlSource.fetch(dati.senato.it, ...)→ POST fallisce → GET fallback → dati CSV restituiti.Note
test_sparql_fetch_post_timeout_falls_back_to_getcopre il caso timeouttest_sparql_fetch_get_fallback_5xx_raisescopre il GET fallback con 500