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
11 changes: 11 additions & 0 deletions src/titiler/application/tests/routes/test_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,3 +443,14 @@ def test_json_response_with_nan(rio, app):
assert response.status_code == 200
body = response.json()
assert body["values"][0] is None


@patch("rio_tiler.io.rasterio.rasterio")
def test_invalid_format(rio, app):
"""test /preview endpoint."""
rio.open = mock_rasterio_open

response = app.get(
"/cog/preview.png?url=https://myurl.com/cog.tif&bidx=1&bidx=1&bidx=1&bidx=1&rescale=0,1000&max_size=256"
)
assert response.status_code == 400
2 changes: 2 additions & 0 deletions src/titiler/core/titiler/core/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
InvalidBandName,
InvalidColorFormat,
InvalidExpression,
InvalidFormat,
MissingAssets,
MissingBands,
RioTilerError,
Expand Down Expand Up @@ -48,6 +49,7 @@ class BadRequestError(TilerError):
RioTilerError: status.HTTP_500_INTERNAL_SERVER_ERROR,
Exception: status.HTTP_500_INTERNAL_SERVER_ERROR,
InvalidExpression: status.HTTP_400_BAD_REQUEST,
InvalidFormat: status.HTTP_400_BAD_REQUEST,
}


Expand Down