Closed
Conversation
- Replace urllib urlopen() with httpx.get() with a 30s timeout - Remove local file path support entirely (was an unrestricted read) - Reject any string input that is not an HTTP(S) URL
allow_origins=["*"] + allow_credentials=True is a dangerous CORS combination. Credentials are not needed for this public data API.
Change `from None` to `from e` so the original traceback is retained when ProcessorExecuteError is raised.
Read OGCAPI_BASE_URL from env so Prefect workers outside the API container can reach the correct endpoint.
Asserts are stripped with python -O. These invariants guard real logic so they need to be proper exceptions.
YAML files don't change at runtime so there's no need to re-read and re-parse them on every request.
Catch (yaml.YAMLError, OSError) instead of bare Exception so unexpected errors like TypeError from malformed data surface immediately instead of silently dropping datasets.
If to_netcdf() raises, remove the orphaned temp file before re-raising the exception.
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.
Summary
Addresses red flags found during code review of
src/eo_api. Security issues, reliability problems, and correctness fixes.Security hardening
zonal_statistics.py): replacedurlopen()withhttpx.get()(30s timeout), removed local file path support entirelymain.py): droppedallow_credentials=True(not needed for public data API)Reliability
chirps3_dhis2_pipeline.py): changedfrom Nonetofrom eto preserve tracebacksregistry.py): narrowed bareexcept Exceptionto(yaml.YAMLError, OSError)Correctness + cleanup
tasks.py):OGCAPI_BASE_URLnow read from env var with localhost fallbackserialize.py): replaced asserts (stripped with-O) with proper exceptionsregistry.py): added@lru_cachetolist_datasets()to avoid re-parsing YAML on every requestserialize.py): clean up temp file ifto_netcdf()fails