Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/)

## [Unreleased]

## [v3.10.1] - 2025-07-26

### Fixed
- Reverted path cleaning changes that removed `./` prefix from relative paths, which was causing compatibility issues with tools like stac-check. The validator now correctly preserves the `./` prefix for relative paths in the current directory. [#266](https://github.com/stac-utils/stac-validator/pull/266)

## [v3.10.0] - 2025-07-20

Expand Down Expand Up @@ -298,7 +302,8 @@ The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/)
- With the newest version - 1.0.0-beta.2 - items will run through jsonchema validation before the PySTAC validation. The reason for this is that jsonschema will give more informative error messages. This should be addressed better in the future. This is not the case with the --recursive option as time can be a concern here with larger collections.
- Logging. Various additions were made here depending on the options selected. This was done to help assist people to update their STAC collections.

[Unreleased]: https://github.com/sparkgeo/stac-validator/compare/v3.10.0..main
[Unreleased]: https://github.com/sparkgeo/stac-validator/compare/v3.10.1..main
[v3.10.1]: https://github.com/sparkgeo/stac-validator/compare/v3.10.0..v3.10.1
[v3.10.0]: https://github.com/sparkgeo/stac-validator/compare/v3.9.3..v3.10.0
[v3.9.3]: https://github.com/sparkgeo/stac-validator/compare/v3.9.2..v3.9.3
[v3.9.2]: https://github.com/sparkgeo/stac-validator/compare/v3.9.1..v3.9.2
Expand Down
32 changes: 6 additions & 26 deletions stac_validator/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,32 +684,12 @@ def recursive_validator(self, stac_type: str) -> bool:
if link["rel"] in ("child", "item"):
address = link["href"]
if not is_valid_url(address):
if is_valid_url(str(base_url)):
# If base is a URL, handle URL joining
from urllib.parse import urljoin

self.stac_file = urljoin(
(
str(base_url) + "/"
if not str(base_url).endswith("/")
else str(base_url)
),
address,
)
else:
# Handle local file paths
current_dir = os.path.dirname(
os.path.abspath(str(base_url))
)
self.stac_file = os.path.normpath(
os.path.join(current_dir, address)
)
# Convert to relative path for cleaner output if it's under the current working directory
try:
self.stac_file = os.path.relpath(self.stac_file)
except ValueError:
# If paths are on different drives (Windows) or other relpath issues, use the absolute path
pass
path_parts = str(base_url).split("/")
path_parts.pop(-1)
root = path_parts[0]
for i in range(1, len(path_parts)):
root = f"{root}/{path_parts[i]}"
self.stac_file = f"{root}/{address}"
else:
self.stac_file = address

Expand Down
26 changes: 13 additions & 13 deletions tests/test_recursion.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_recursive_lvl_4_local_v100():
},
{
"version": "1.0.0",
"path": "tests/test_data/local_cat/open-science-catalog-testing/projects/catalog.json",
"path": "tests/test_data/local_cat/open-science-catalog-testing/./projects/catalog.json",
"schema": [
"https://schemas.stacspec.org/v1.0.0/catalog-spec/json-schema/catalog.json"
],
Expand All @@ -36,7 +36,7 @@ def test_recursive_lvl_4_local_v100():
},
{
"version": "1.0.0",
"path": "tests/test_data/local_cat/open-science-catalog-testing/projects/3d-earth/collection.json",
"path": "tests/test_data/local_cat/open-science-catalog-testing/./projects/./3d-earth/collection.json",
"schema": [
"https://stac-extensions.github.io/osc/v1.0.0-rc.3/schema.json",
"https://stac-extensions.github.io/contacts/v0.1.1/schema.json",
Expand All @@ -49,7 +49,7 @@ def test_recursive_lvl_4_local_v100():
},
{
"version": "1.0.0",
"path": "tests/test_data/local_cat/open-science-catalog-testing/projects/3dctrl/collection.json",
"path": "tests/test_data/local_cat/open-science-catalog-testing/./projects/./3dctrl/collection.json",
"schema": [
"https://stac-extensions.github.io/osc/v1.0.0-rc.3/schema.json",
"https://stac-extensions.github.io/contacts/v0.1.1/schema.json",
Expand Down Expand Up @@ -156,7 +156,7 @@ def test_recursion_collection_local_v1rc1():
},
{
"version": "1.0.0-rc.1",
"path": "tests/test_data/1rc1/simple-item.json",
"path": "tests/test_data/1rc1/./simple-item.json",
"schema": [
"https://schemas.stacspec.org/v1.0.0-rc.1/item-spec/json-schema/item.json"
],
Expand All @@ -167,7 +167,7 @@ def test_recursion_collection_local_v1rc1():
},
{
"version": "1.0.0-rc.1",
"path": "tests/test_data/1rc1/core-item.json",
"path": "tests/test_data/1rc1/./core-item.json",
"schema": [
"https://schemas.stacspec.org/v1.0.0-rc.1/item-spec/json-schema/item.json"
],
Expand All @@ -178,7 +178,7 @@ def test_recursion_collection_local_v1rc1():
},
{
"version": "1.0.0-rc.1",
"path": "tests/test_data/1rc1/extended-item.json",
"path": "tests/test_data/1rc1/./extended-item.json",
"schema": [
"https://cdn.staclint.com/v1.0.0-rc.1/extension/eo.json",
"https://cdn.staclint.com/v1.0.0-rc.1/extension/projection.json",
Expand Down Expand Up @@ -212,7 +212,7 @@ def test_recursion_collection_local_v1rc2():
},
{
"version": "1.0.0-rc.2",
"path": "tests/test_data/1rc2/simple-item.json",
"path": "tests/test_data/1rc2/./simple-item.json",
"schema": [
"https://schemas.stacspec.org/v1.0.0-rc.2/item-spec/json-schema/item.json"
],
Expand All @@ -223,7 +223,7 @@ def test_recursion_collection_local_v1rc2():
},
{
"version": "1.0.0-rc.2",
"path": "tests/test_data/1rc2/core-item.json",
"path": "tests/test_data/1rc2/./core-item.json",
"schema": [
"https://schemas.stacspec.org/v1.0.0-rc.2/item-spec/json-schema/item.json"
],
Expand All @@ -234,7 +234,7 @@ def test_recursion_collection_local_v1rc2():
},
{
"version": "1.0.0-rc.2",
"path": "tests/test_data/1rc2/extended-item.json",
"path": "tests/test_data/1rc2/./extended-item.json",
"schema": [
"https://stac-extensions.github.io/eo/v1.0.0/schema.json",
"https://stac-extensions.github.io/projection/v1.0.0/schema.json",
Expand Down Expand Up @@ -270,7 +270,7 @@ def test_recursion_collection_local_2_v1rc2():
},
{
"version": "1.0.0-rc.2",
"path": "tests/test_data/1rc2/extensions-collection/proj-example/proj-example.json",
"path": "tests/test_data/1rc2/extensions-collection/./proj-example/proj-example.json",
"schema": [
"https://schemas.stacspec.org/v1.0.0-rc.2/item-spec/json-schema/item.json"
],
Expand Down Expand Up @@ -298,7 +298,7 @@ def test_recursion_with_bad_item():
assert stac.message == [
{
"version": "1.0.0",
"path": "tests/test_data/v100/bad-item.json",
"path": "tests/test_data/v100/./bad-item.json",
"schema": [
"https://schemas.stacspec.org/v1.0.0/item-spec/json-schema/item.json"
],
Expand Down Expand Up @@ -331,7 +331,7 @@ def test_recursion_with_bad_item_trace_recursion():
},
{
"version": "1.0.0",
"path": "tests/test_data/v100/bad-item.json",
"path": "tests/test_data/v100/./bad-item.json",
"schema": [
"https://schemas.stacspec.org/v1.0.0/item-spec/json-schema/item.json"
],
Expand All @@ -356,7 +356,7 @@ def test_recursion_with_bad_child_collection():
assert stac.message == [
{
"version": "1.0.0",
"path": "tests/test_data/v100/collection-only/bad-collection.json",
"path": "tests/test_data/v100/./collection-only/bad-collection.json",
"schema": [
"https://schemas.stacspec.org/v1.0.0/collection-spec/json-schema/collection.json"
],
Expand Down