Skip to content

test(serverless): cover int input for float fields in rp_validator - #753

Open
Trenyx wants to merge 1 commit into
runpod:mainfrom
Trenyx:test/validate-int-for-float
Open

Trenyx wants to merge 1 commit into
runpod:mainfrom
Trenyx:test/validate-int-for-float

Conversation

@Trenyx

@Trenyx Trenyx commented Nov 25, 2026

Copy link
Copy Markdown

If rp_validator.validate stopped accepting an int for a float field, a worker with a schema like {"temperature": {"type": float, ...}} would reject every request that sends "temperature": 1, and no test would notice. JSON clients send whole-number floats that way all the time (JavaScript's JSON.stringify(1.0) is 1), so callers would get "temperature should be <class 'float'> type, not <class 'int'>" for valid input.

Tests only: one test (+12 lines) in tests/test_serverless/test_utils/test_validate.py. No change to library code.

The test validates {"a": 1} against {"a": {"type": float, "required": True}} and checks there are no errors and the validated value is the float 1.0. That is the conversion _validate_input_against_schema already does ("Enforce floats to be floats").

How it was checked

On main ddd8972:

  • uv run pytest tests/test_serverless/test_utils/test_validate.py: 10 passed.
  • ruff check is clean on the file, and Black leaves the new lines unchanged.
  • With int dropped from the accepted types in that float check (type(...) in [float]), this new test is the only one that fails. The rest of the suite (everything except tests/test_apps, which does not use the validator) still passes: 2043 passed.

This test was written with Claude Code during a planted-bug run by SK @ Trenyx.

validate() converts an int given for a float field to float, so a JSON
request with "temperature": 1 passes a float schema. No test pinned that
conversion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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.

1 participant