From 34be9e4920cd9066e8d90a15a5fded65272ced37 Mon Sep 17 00:00:00 2001 From: James Banting Date: Fri, 10 Apr 2020 10:22:20 -0700 Subject: [PATCH 1/4] [error_messaging] added better error messaging --- stac_validator/stac_validator.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stac_validator/stac_validator.py b/stac_validator/stac_validator.py index 930e7ac2..c8b04d81 100755 --- a/stac_validator/stac_validator.py +++ b/stac_validator/stac_validator.py @@ -205,7 +205,11 @@ def run(self): message["valid_stac"] = True except ValidationError as e: self.status[f"{self.stac_type}s"]["invalid"] += 1 - message.update(self.create_err_msg("ValidationError", e.message)) + if e.absolute_path: + err_msg = f"{e.message}. Error is in {' -> '.join(e.absolute_path)}" + else: + err_msg = f"{e.message} of the root of the STAC object" + message.update(self.create_err_msg("ValidationError", err_msg )) self.message.append(message) From 979547abec483780e05924402c56dd3d83bf9fbf Mon Sep 17 00:00:00 2001 From: James Banting Date: Fri, 10 Apr 2020 10:51:50 -0700 Subject: [PATCH 2/4] [error_messaging] capture array position in error messaging --- stac_validator/stac_validator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stac_validator/stac_validator.py b/stac_validator/stac_validator.py index c8b04d81..67bb31d3 100755 --- a/stac_validator/stac_validator.py +++ b/stac_validator/stac_validator.py @@ -206,7 +206,7 @@ def run(self): except ValidationError as e: self.status[f"{self.stac_type}s"]["invalid"] += 1 if e.absolute_path: - err_msg = f"{e.message}. Error is in {' -> '.join(e.absolute_path)}" + err_msg = f"{e.message}. Error is in {' -> '.join([str(i) for i in e.absolute_path])}" else: err_msg = f"{e.message} of the root of the STAC object" message.update(self.create_err_msg("ValidationError", err_msg )) From d5a7f7c5baf741cbab5041e8a0a4b0e05eb4e505 Mon Sep 17 00:00:00 2001 From: James Banting Date: Fri, 10 Apr 2020 11:18:02 -0700 Subject: [PATCH 3/4] [error_messaging] check version string --- stac_validator/stac_validator.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stac_validator/stac_validator.py b/stac_validator/stac_validator.py index 67bb31d3..1b216004 100755 --- a/stac_validator/stac_validator.py +++ b/stac_validator/stac_validator.py @@ -74,7 +74,10 @@ def __init__( level=numeric_log_level, ) logging.info("STAC Validator Started.") - self.stac_version = version + if version in ['master', 'latest'] or version.startswith("v"): + self.stac_version = version + else: + self.stac_version = f"v{version}" self.stac_file = stac_file.strip() self.dirpath = tempfile.mkdtemp() self.stac_spec_host = stac_spec_host From 4baea37c3dda2730b82e06706538f4d65e443777 Mon Sep 17 00:00:00 2001 From: James Banting Date: Tue, 14 Apr 2020 10:26:20 -0700 Subject: [PATCH 4/4] [error_messaging] updated error message testing --- tests/test_stac_validator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_stac_validator.py b/tests/test_stac_validator.py index 8d2e1d93..71465e1b 100644 --- a/tests/test_stac_validator.py +++ b/tests/test_stac_validator.py @@ -55,7 +55,7 @@ def test_bad_item_validation_v090_verbose(): "schema": "https://cdn.staclint.com/v0.9.0/item.json", "valid_stac": False, "error_type": "ValidationError", - "error_message": "'id' is a required property", + "error_message": "'id' is a required property of the root of the STAC object", } ]