fix: graceful 400 on datetime sel against a stale int64 axis#123
Open
lhoupert wants to merge 1 commit into
Open
fix: graceful 400 on datetime sel against a stale int64 axis#123lhoupert wants to merge 1 commit into
lhoupert wants to merge 1 commit into
Conversation
A `sel` value was cast with `da[dim].dtype.type(v)`. Against a stale/legacy
int64 `time` axis, `np.int64("2026-06-08T17:38:52")` raised ValueError that
escaped as HTTP 500. Wrap the cast in try/except and raise BadRequestError
(already mapped to 400). No datetime branch is added: `dtype.type` is already
`np.datetime64` for a datetime axis, so the happy path is unchanged.
The sel-tile benchmark guards this cast path against regression.
Split out of #119 per review.
Refs #118 (sel half; issue closes when the cache fix lands too).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
|
||
| def test_sel_on_int64_axis_raises_bad_request(geozarr_3d_dataset): | ||
| """A datetime `sel` against a (stale) int64 time axis degrades to 4xx, not 500.""" | ||
| from titiler.core.errors import BadRequestError |
Collaborator
There was a problem hiding this comment.
can we put this outside the function?
| sel=["time=2022-01-02T00:00:00.000000000"], | ||
| ) | ||
|
|
||
| _ = benchmark(_tile) |
Collaborator
There was a problem hiding this comment.
do we really need the benchmark this?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the
selhalf of #118 (the stale-cache fix is a separate PR).Problem
A
selvalue was cast withda[dim].dtype.type(v). Against a stale/legacy int64timeaxis,np.int64("2026-06-08T17:38:52")raisedValueErrorthat escaped as HTTP 500.Fix
Wrap the cast in
try/exceptand raiseBadRequestError(already mapped to 400). No datetime branch is added:dtype.typeis alreadynp.datetime64for a datetime axis, so the happy path is unchanged.Tests
sel→BadRequestError; datetime64 happy path preserved.uv run pytest→ 102 passed; pre-commit clean.Split out of #119 per review.
Refs #118 (sel half; close the issue once the cache PR also lands).
🤖 Generated with Claude Code