Skip to content
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

Remove links from default include list #524

Closed
wants to merge 2 commits into from

Conversation

gadomski
Copy link
Member

@gadomski gadomski commented Feb 7, 2023

Related Issue(s):

This is one of two PRs that would fix stac-utils/stac-fastapi-pgstac#27; the other is #527. We should merge one and close the other.

Description:

The fields extension is used to include/exclude fields on items returned by /search (and /collections/{cid}/items). If a field is not present in include or exclude, the extension does not specify whether that field should be present on the response items (though it does provide guidance). Currently, links is included by default, even if it is not present in the include list. This PR changes that behavior to exclude links by default if there is an include list.

sqlalchemy uses FieldsExtension.default_includes, so its fix was pretty easy
-- I did have to add an explicit include+exclude check to the search function to ensure the fields extension was applied only if either include or exclude was set. pgstac was a little trickier, because it doesn't use the default_includes list.

I did modify one existing test -- test_app_fields_extension in the sqlalchemy tests was assuming fields would be stripped just by providing a collections parameter to the query, which I think is incorrect -- I added an explicit include field to the test.

PR Checklist:

  • Code is formatted and linted (run pre-commit run --all-files)
  • Tests pass (run make test)
  • Documentation has been updated to reflect changes, if applicable, and docs build successfully (run make docs)
  • Changes are added to the CHANGELOG.

**sqlalchemy** uses `FieldsExtension.default_includes`, so its fix was pretty
*easy
-- I did have to add an explicit include+exclude check to the search function to
ensure the fields extension was applied _only if_ either `include` or `exclude`
was set. **pgstac** was a little trickier, because it doesn't use the
`default_includes` list.

I did modify one existing test -- `test_app_fields_extension` in the
**sqlalchemy** tests was assuming fields would be stripped just by providing a
`collections` parameter to the query, which I think was incorrect -- I added an
explicit `include` field to the test.
@gadomski
Copy link
Member Author

Converting to draft until stac-api-extensions/fields#5 lands.

@gadomski gadomski marked this pull request as draft February 22, 2023 15:32
@gadomski
Copy link
Member Author

gadomski commented Mar 7, 2023

Closing as blocked by stac-api-extensions/fields#5.

@gadomski gadomski closed this Mar 7, 2023
@gadomski gadomski deleted the issues/395-drop-nonincluded-links branch May 9, 2023 18:56
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.

PgSTAC: Fields extension includes links even if not listed in includes
1 participant