From c5c8a3de543ee99f756d15a9607e6a057a4abd3d Mon Sep 17 00:00:00 2001 From: Chris Arridge Date: Mon, 12 Oct 2026 11:54:44 +0100 Subject: [PATCH 1/2] fix: lib360dataquality: force caching of schema and handle exceptions Use the force_cache option in libcove to force caching of 360 schema so if schema URLs are temporarily unavailable the library can still function. If the requesting the schema fails for any reason we also add some exception handling to improve debugging and logging of errors. This closes https://github.com/ThreeSixtyGiving/dataquality/issues/190. --- lib360dataquality/cove/schema.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib360dataquality/cove/schema.py b/lib360dataquality/cove/schema.py index ef8d88f..330ddc9 100644 --- a/lib360dataquality/cove/schema.py +++ b/lib360dataquality/cove/schema.py @@ -45,14 +45,24 @@ def __init__(self, data_dir, local_pkg_schema_path=None, local_grant_schema_path self._pkg_schema_obj = json.load(f) else: pkg_schema_url = urljoin(config["schema_host"], self.pkg_schema_name) - self._pkg_schema_obj = get_request(pkg_schema_url).json() + try: + self._pkg_schema_obj = get_request(pkg_schema_url, force_cache=True).json() + except json.JSONDecodeError as exc: + raise Exception("Could not parse JSON from package schema") from exc + except Exception as exc: + raise Exception("Could not fetch package schema") from exc if local_grant_schema_path: with open(local_grant_schema_path) as f: self._schema_obj = json.load(f) else: schema_url = urljoin(config["schema_host"], self.schema_name) - self._schema_obj = get_request(schema_url).json() + try: + self._schema_obj = get_request(schema_url, force_cache=True).json() + except json.JSONDecodeError as exc: + raise Exception("Could not parse JSON from grant schema") from exc + except Exception as exc: + raise Exception("Could not fetch grant schema") from exc # Update the pkg schema to no longer point to an external reference for the # grants schema. From 91353ba9bd8216c412c16acf97016b737a2b3bd6 Mon Sep 17 00:00:00 2001 From: Chris Arridge Date: Mon, 12 Oct 2026 12:24:21 +0100 Subject: [PATCH 2/2] chore: updated gitignore to ignore hypothesis files in subdirectories --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1366b03..928b68b 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,7 @@ htmlcov docs/_build .cache/* .pytest_cache/ -.hypothesis/* +**/.hypothesis/* geckodriver.log ghostdriver.log cove/lib/org-ids.json