Skip to content

fix Link 'label:assets' field type as list #183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

fmigneault
Copy link
Contributor

Posting a STAC Item that contains label:assets as defined below results in a validation error since the str doesn't match the expected list (https://github.com/stac-extensions/label?tab=readme-ov-file#links-source-imagery).

{
  "links": [
        {
          "rel": "source",
          "href": "https://hirondelle.crim.ca/data/stac/EuroSAT/data/full/ds/images/remote_sensing/otherDatasets/sentinel_2/tif/Pasture/Pasture_1687.tif",
          "type": "image/tiff; application=geotiff",
          "title": "Raster Pasture_1687 with Pasture class",
          "ml-aoi:role": "label",
          "label:assets": [
            "labels",
            "raster"
          ]
        }
  ]
}

I've tested that the fix works as expected by running our https://github.com/crim-ca/stac-app (STAC-FastAPI) with this stac-pydantic patch applied.

@fmigneault
Copy link
Contributor Author

@vincentsarago
Hi. It is possible to validate this fix and its inclusion into STAC-FastAPI/pgstac?
This is blocking us from migrating our app to latest definitions using the label extension.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.52%. Comparing base (a927d25) to head (e811d0d).
Report is 129 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #183      +/-   ##
==========================================
- Coverage   96.59%   95.52%   -1.07%     
==========================================
  Files          25       25              
  Lines         587      671      +84     
==========================================
+ Hits          567      641      +74     
- Misses         20       30      +10     
Flag Coverage Δ
unittests 95.52% <100.00%> (-1.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

min_length=1,
alias="label:assets",
validation_alias=AliasChoices("label:assets", "label_assets", "label"),
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 well to be honest I believe we should just remove the label attribute and let extension be handled with validate_extensions

https://github.com/stac-utils/stac-pydantic?tab=readme-ov-file#extensions

Copy link
Contributor Author

@fmigneault fmigneault Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. That makes the most sense IMO as well.
Are all extensions validated automatically by STAC-FastAPI when POSTing a STAC Item?
I don't see explicit calls to validate_extensions in the code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think they are validated but we could add an option. Can you open an issue in stac-fastapi?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I can look into adding that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feature ready: stac-utils/stac-fastapi-pgstac#269

Replacement for this PR: #184

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.

3 participants