stac-validator 3.9.0__tar.gz → 3.9.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {stac_validator-3.9.0 → stac_validator-3.9.2}/PKG-INFO +1 -1
- {stac_validator-3.9.0 → stac_validator-3.9.2}/setup.py +1 -1
- {stac_validator-3.9.0 → stac_validator-3.9.2}/stac_validator/validate.py +53 -9
- {stac_validator-3.9.0 → stac_validator-3.9.2}/stac_validator.egg-info/PKG-INFO +1 -1
- {stac_validator-3.9.0 → stac_validator-3.9.2}/LICENSE +0 -0
- {stac_validator-3.9.0 → stac_validator-3.9.2}/README.md +0 -0
- {stac_validator-3.9.0 → stac_validator-3.9.2}/pyproject.toml +0 -0
- {stac_validator-3.9.0 → stac_validator-3.9.2}/setup.cfg +0 -0
- {stac_validator-3.9.0 → stac_validator-3.9.2}/stac_validator/__init__.py +0 -0
- {stac_validator-3.9.0 → stac_validator-3.9.2}/stac_validator/stac_validator.py +0 -0
- {stac_validator-3.9.0 → stac_validator-3.9.2}/stac_validator/utilities.py +0 -0
- {stac_validator-3.9.0 → stac_validator-3.9.2}/stac_validator.egg-info/SOURCES.txt +0 -0
- {stac_validator-3.9.0 → stac_validator-3.9.2}/stac_validator.egg-info/dependency_links.txt +0 -0
- {stac_validator-3.9.0 → stac_validator-3.9.2}/stac_validator.egg-info/entry_points.txt +0 -0
- {stac_validator-3.9.0 → stac_validator-3.9.2}/stac_validator.egg-info/requires.txt +0 -0
- {stac_validator-3.9.0 → stac_validator-3.9.2}/stac_validator.egg-info/top_level.txt +0 -0
|
@@ -267,21 +267,39 @@ class StacValidate:
|
|
|
267
267
|
schema_value = str(self.schema)
|
|
268
268
|
schema_field: List[str] = [schema_value] if schema_value else []
|
|
269
269
|
|
|
270
|
+
# Initialize the message with common fields
|
|
270
271
|
message: Dict[str, Union[str, bool, List[str], Dict[str, Any]]] = {
|
|
271
272
|
"version": version_str,
|
|
272
273
|
"path": path_str,
|
|
273
|
-
"schema": schema_field, #
|
|
274
|
+
"schema": schema_field, # All schemas that were checked
|
|
274
275
|
"valid_stac": False,
|
|
275
276
|
"error_type": err_type,
|
|
276
277
|
"error_message": err_msg,
|
|
278
|
+
"failed_schema": "", # Will be populated if we can determine which schema failed
|
|
277
279
|
}
|
|
278
280
|
|
|
281
|
+
# Try to extract the failed schema from the error message if it's a validation error
|
|
282
|
+
if error_obj and hasattr(error_obj, "schema"):
|
|
283
|
+
if isinstance(error_obj.schema, dict) and "$id" in error_obj.schema:
|
|
284
|
+
message["failed_schema"] = error_obj.schema["$id"]
|
|
285
|
+
elif hasattr(error_obj, "schema_url"):
|
|
286
|
+
message["failed_schema"] = error_obj.schema_url
|
|
287
|
+
# If we can't find a schema ID, try to get it from the schema map
|
|
288
|
+
elif schema_field and len(schema_field) == 1:
|
|
289
|
+
message["failed_schema"] = schema_field[0]
|
|
290
|
+
|
|
279
291
|
if self.verbose and error_obj is not None:
|
|
280
292
|
verbose_err = self._create_verbose_err_msg(error_obj)
|
|
281
293
|
if isinstance(verbose_err, dict):
|
|
282
294
|
message["error_verbose"] = verbose_err
|
|
283
295
|
else:
|
|
284
296
|
message["error_verbose"] = {"detail": str(verbose_err)}
|
|
297
|
+
# Add recommendation to check the schema if the error is not clear
|
|
298
|
+
if "failed_schema" in message and message["failed_schema"]:
|
|
299
|
+
message["recommendation"] = (
|
|
300
|
+
"If the error is unclear, please check the schema documentation at: "
|
|
301
|
+
f"{message['failed_schema']}"
|
|
302
|
+
)
|
|
285
303
|
else:
|
|
286
304
|
message["recommendation"] = (
|
|
287
305
|
"For more accurate error information, rerun with --verbose."
|
|
@@ -459,25 +477,39 @@ class StacValidate:
|
|
|
459
477
|
if e.context:
|
|
460
478
|
e = best_match(e.context) # type: ignore
|
|
461
479
|
valid = False
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
)
|
|
467
|
-
|
|
468
|
-
|
|
480
|
+
# Get the current schema (extension) that caused the validation error
|
|
481
|
+
failed_schema = self._original_schema_paths.get(extension, extension)
|
|
482
|
+
# Build the error message with path information
|
|
483
|
+
path_info = (
|
|
484
|
+
f"Error is in {' -> '.join(map(str, e.absolute_path))} "
|
|
485
|
+
if e.absolute_path
|
|
486
|
+
else ""
|
|
487
|
+
)
|
|
488
|
+
err_msg = f"{e.message}. {path_info}"
|
|
489
|
+
|
|
490
|
+
# Create the error message with the original error object
|
|
469
491
|
message = self.create_err_msg(
|
|
470
492
|
err_type="JSONSchemaValidationError",
|
|
471
493
|
err_msg=err_msg,
|
|
472
494
|
error_obj=verbose_error,
|
|
473
495
|
)
|
|
496
|
+
|
|
497
|
+
# Set the failed_schema in the message if we have it
|
|
498
|
+
if failed_schema:
|
|
499
|
+
message["failed_schema"] = failed_schema
|
|
474
500
|
return message
|
|
475
501
|
|
|
476
502
|
except Exception as e:
|
|
477
503
|
if self.recursive:
|
|
478
504
|
raise
|
|
479
505
|
valid = False
|
|
480
|
-
|
|
506
|
+
# Include the current schema in the error message for other types of exceptions
|
|
507
|
+
current_schema = (
|
|
508
|
+
self._original_schema_paths.get(extension, extension)
|
|
509
|
+
if "extension" in locals()
|
|
510
|
+
else "unknown schema"
|
|
511
|
+
)
|
|
512
|
+
err_msg = f"{e} [Schema: {current_schema}]. Error in Extensions."
|
|
481
513
|
return self.create_err_msg(
|
|
482
514
|
err_type="Exception", err_msg=err_msg, error_obj=e
|
|
483
515
|
)
|
|
@@ -649,10 +681,22 @@ class StacValidate:
|
|
|
649
681
|
Args:
|
|
650
682
|
item_collection (dict): The dictionary representation of the item collection.
|
|
651
683
|
"""
|
|
684
|
+
# Store the original stac_file to restore it later
|
|
685
|
+
original_stac_file = self.stac_file
|
|
686
|
+
|
|
652
687
|
for item in item_collection["features"]:
|
|
688
|
+
# Update the path to include the item ID for better traceability
|
|
689
|
+
if isinstance(original_stac_file, str) and "id" in item:
|
|
690
|
+
# Remove any query string from the URL before appending the item ID
|
|
691
|
+
base_url = original_stac_file.split("?")[0]
|
|
692
|
+
self.stac_file = f"{base_url}/{item['id']}"
|
|
693
|
+
|
|
653
694
|
self.schema = ""
|
|
654
695
|
self.validate_dict(item)
|
|
655
696
|
|
|
697
|
+
# Restore the original stac_file
|
|
698
|
+
self.stac_file = original_stac_file
|
|
699
|
+
|
|
656
700
|
def validate_collections(self) -> None:
|
|
657
701
|
"""
|
|
658
702
|
Validate STAC Collections from a /collections endpoint.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|