From 9c30f9f76f44404245d9adfcba92651857c68610 Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Thu, 29 Oct 2020 16:05:13 -0400 Subject: [PATCH 1/3] common: Log error for invalid JSON Schema in which "properties" values aren't JSON Schema --- libcove/lib/common.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libcove/lib/common.py b/libcove/lib/common.py index d52be5d..4744195 100644 --- a/libcove/lib/common.py +++ b/libcove/lib/common.py @@ -4,6 +4,7 @@ import fcntl import functools import json +import logging import os import re from collections import OrderedDict @@ -43,6 +44,8 @@ "array": "{}'{}' is not a JSON array", } +logger = logging.getLogger(__name__) + def unique_ids(validator, ui, instance, schema, id_name="id"): if ui and validator.is_type(instance, "array"): @@ -1105,6 +1108,14 @@ def add_is_codelist(obj): release.tag in core schema at the moment.""" for prop, value in obj.get("properties", {}).items(): + if not isinstance(value, dict): + logger.warning( + "A 'properties' object contains a {!r} value that is not a JSON Schema: {!r}".format( + prop, value + ) + ) + continue + if "codelist" in value: if "array" in value.get("type", ""): value["items"]["isCodelist"] = True From a416a24ce2f0f7501bd5b1d39db8898366c9fa18 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 4 Nov 2020 16:02:17 +0000 Subject: [PATCH 2/3] Add CHANGELOG entry --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec98e81..20b510f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed + +- Don't error when JSON schema "properties" values aren't JSON Schema, and log a warning instead https://github.com/OpenDataServices/lib-cove/pull/71 + ## [0.20.1] - 2020-10-27 ### Fixed From 16c26666bf7dcf810a4bab112c6ca20f0e92b098 Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Wed, 4 Nov 2020 16:03:50 +0000 Subject: [PATCH 3/3] release: Make 0.20.2 release --- CHANGELOG.md | 2 ++ setup.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20b510f..a9989e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [0.20.2] - 2020-11-04 + ### Fixed - Don't error when JSON schema "properties" values aren't JSON Schema, and log a warning instead https://github.com/OpenDataServices/lib-cove/pull/71 diff --git a/setup.py b/setup.py index 706476b..de481e7 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="libcove", - version="0.20.1", + version="0.20.2", author="Open Data Services", author_email="code@opendataservices.coop", url="https://github.com/OpenDataServices/lib-cove",