Skip to content

Fix dataset prefix matching in STAC server#5

Merged
TheGreatAlgo merged 2 commits into
mainfrom
load-dataset-bug
Jun 16, 2026
Merged

Fix dataset prefix matching in STAC server#5
TheGreatAlgo merged 2 commits into
mainfrom
load-dataset-bug

Conversation

@eloramirez1356

Copy link
Copy Markdown
Collaborator

This pull request improves the accuracy and robustness of dataset resolution for ERA5 and ERA5-Land datasets, ensuring that dataset IDs are matched exactly rather than by prefix. This prevents accidental conflation of similar dataset names (such as precipitation_total and precipitation_total_land). It also adds comprehensive tests to verify this behavior and updates the documentation to clarify how to load these datasets.

Dataset resolution improvements:

  • Refactored dataset matching logic in src/stac/stac-server.ts to use a new featureMatchesDataset function, ensuring that datasets are matched exactly rather than by prefix, preventing collisions between similar dataset names (e.g., precipitation_total vs. precipitation_total_land). [1] [2]
  • Added a helper function datasetIdFromItemId to extract dataset IDs from item IDs for legacy fallback, ensuring exact matches only.

Testing enhancements:

  • Added a new test suite in tests/stac-server.test.ts to verify that only exact dataset matches are resolved and that prefix collisions do not occur. Tests cover both positive and negative cases as well as legacy item ID fallback.
  • Improved test setup by cleaning up global stubs after each test to prevent cross-test interference.

Documentation updates:

  • Updated README.md to clarify the distinction between ERA5 and ERA5-Land datasets and provided example code for loading each type, helping users avoid dataset confusion.

Test infrastructure:

  • Updated test imports to include afterEach and vi for better test isolation and mocking.

@eloramirez1356 eloramirez1356 self-assigned this Jun 15, 2026
@TheGreatAlgo TheGreatAlgo merged commit 867fbf9 into main Jun 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants