From 415d9e4cbbb5286915924d16d1a6503a3a94dee9 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 14 Mar 2022 22:23:56 -0600 Subject: [PATCH 1/3] Include detail about failing item in message --- stac_validator/validate.py | 5 ++--- tests/test_recursion.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/stac_validator/validate.py b/stac_validator/validate.py index 2c97d7b9..52c332f4 100644 --- a/stac_validator/validate.py +++ b/stac_validator/validate.py @@ -314,9 +314,8 @@ def run(cls): except Exception as e: message.update(cls.create_err_msg("Exception", str(e))) - message["valid_stac"] = cls.valid - - if not cls.recursive: + if len(message) > 0: + message["valid_stac"] = cls.valid cls.message.append(message) if cls.log != "": diff --git a/tests/test_recursion.py b/tests/test_recursion.py index 7de941d9..4247c62f 100644 --- a/tests/test_recursion.py +++ b/tests/test_recursion.py @@ -304,3 +304,32 @@ def test_recursion_without_max_depth(): stac = stac_validator.StacValidate(stac_file, recursive=True) stac.run() assert len(stac.message) == 6 + + +def test_recursion_with_bad_item(): + stac_file = "tests/test_data/v100/catalog-with-bad-item.json" + stac = stac_validator.StacValidate(stac_file, recursive=True) + stac.run() + assert len(stac.message) == 2 + assert stac.message == [ + { + "version": "1.0.0", + "path": "tests/test_data/v100/catalog-with-bad-item.json", + "schema": [ + "https://schemas.stacspec.org/v1.0.0/catalog-spec/json-schema/catalog.json" + ], + "valid_stac": True, + "asset_type": "CATALOG", + "validation_method": "recursive", + }, + { + "version": "1.0.0", + "path": "tests/test_data/v100/./bad-item.json", + "schema": [ + "https://schemas.stacspec.org/v1.0.0/item-spec/json-schema/item.json" + ], + "valid_stac": False, + "error_type": "ValidationError", + "error_message": "'id' is a required property of the root of the STAC object", + }, + ] From c974e1b7a939a96dabf954aa4a313e8d81f0e1e9 Mon Sep 17 00:00:00 2001 From: Jonathan Healy Date: Tue, 15 Mar 2022 00:00:08 -0700 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c87c881d..33e27b36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/) ### Fixed - Reordered exception handlers to avoid unreachable code +- Details about invalid items is shown in the message when in recursive mode ## [v3.0.0] - 2022-03-11 From 05a291fdf8199f0bf8c331e7354a4fc28469a9a7 Mon Sep 17 00:00:00 2001 From: Jonathan Healy Date: Tue, 15 Mar 2022 00:02:26 -0700 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33e27b36..d7c03e88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -141,7 +141,10 @@ The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/) - Logging. Various additions were made here depending on the options selected. This was done to help assist people to update their STAC collections. [v3.0.0]: -[v2.5.0]: +[v2.5.0]: +[v2.4.3]: +[v2.4.2]: +[v2.4.1]: [v2.4.0]: [v2.3.0]: [v2.2.0]: