Skip to content

fix: validate quantiles before bytes-path inference - #143

Open
wsj040303 wants to merge 1 commit into
sktime:mainfrom
wsj040303:fix/bytes-quantile-validation-142
Open

wsj040303 wants to merge 1 commit into
sktime:mainfrom
wsj040303:fix/bytes-quantile-validation-142

Conversation

@wsj040303

Copy link
Copy Markdown

Reference Issues/PRs

Fixes #142. Follows up on #137.

What does this implement/fix? Explain your changes.

POST /predict/bytes constructs CoercedPredictRequest directly, bypassing the quantile validation on PredictRequest. An empty list therefore silently produces a point-only forecast, while invalid or duplicate levels fail only after inference has run.

Call the existing _check_quantiles helper from the coerced request validator so invalid levels are rejected before scheduling. Add regression tests for direct construction (including non-finite values), raw multipart requests, and valid values on both routes. The multipart tests modify the wire metadata after encoding so client-side validation cannot hide this gap.

The documented error conventions remain unchanged: JSON validation returns 422; multipart decode/validation returns 400. Neither route schedules an invalid request. None, valid levels, and their input order are preserved.

Does your contribution introduce a new dependency? If yes, which one?

No.

Any other comments?

Validated on Linux with Python 3.13:

  • Before the fix: 15 regression failures (9 direct-construction cases and 6 multipart cases).
  • pytest src/tserve/types/tests/test_models.py src/tserve/server/tests/test_routes.py -q: 79 passed.
  • pytest -q -rs: 210 passed, 2 skipped because optional polars and transformers were not installed (the same skips as the unmodified baseline).
  • pre-commit run --all-files --show-diff-on-failure: passed all applicable hooks.
  • An additional ASGI integration probe using Server() and the real sktime naive model checked 16 requests across both routes: all 12 invalid requests stopped before the scheduler; the 4 valid requests retained the same forecasts and quantile presence as the baseline.

This branch has not been deployed

No deployments
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.

[BUG] CoercedPredictRequest does not validate quantiles, so POST /predict/bytes accepts invalid values

1 participant