Skip to content

fix(stac-api): avoid base64 encoding application/geo+json data #172

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

alukach
Copy link
Member

@alukach alukach commented Jul 25, 2025

When using a REST API with a Lambda Proxy integration (such as when making use of our PrivateLambdaApiGateway, link), data that Mangum converts to base64 is not converted to text by the API Gateway.

By default, Mangum v0.14.1 converts any text data to base64 aside from its builtin defaults1. These defaults do not include application/geo+json which is used by the STAC API. This PR upgrades Mangum (by utilizing stac-fastapi-pgstac's unspecified mangum version2) and configures Mangum to avoid converting any data to base64 that begins with text/ or application/.

Question: Perhaps we should just disable the base64 conversion completely by specifying a text mime type of '' which would match all mime_type in content_type3 lookups?

Footnotes

  1. https://github.com/Kludex/mangum/blob/0.14.1/docs/http.md#text-mime-types

  2. https://github.com/stac-utils/stac-fastapi-pgstac/blob/d43ea548103d0e157d7e22fb70f9ea9fe310509b/setup.py#L49C6-L49C15

  3. https://github.com/Kludex/mangum/blob/0.14.1/mangum/handlers/utils.py#L79

text_mime_types=[
# Avoid base64 encoding any text/* or application/* mime-types
"text/",
"application/"

Choose a reason for hiding this comment

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

I don't know, this feels a little overbroad ... Could we just add the GeoJSON mime type instead?

Copy link
Member Author

@alukach alukach Jul 28, 2025

Choose a reason for hiding this comment

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

Yes, but there's also the Open API spec with application/vnd.oai.openapi;version=3.0. Your point regarding Parquet is valid though, would that have application/vnd.apache.parquet? And we probably wouldn't want to convert application/octet-stream either...

@gadomski
Copy link

Perhaps we should just disable the base64 conversion completely by specifying a text mime type of '' which would match all mime_type in content_type3 lookups?

Not sure... We might as stac-geoparquet (or some other binary format) responses down the road, in which case we might want the conversion?

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