Studio: test that bool inputs yield the precise 'integer or null' error

Regression guard for the validator switch to mode="before". Pre-fix,
vision_image_size: True was rejected with "must be in [256, 2048]
(got 1)" because Pydantic coerced before our check ran. New test
asserts the message now reads "integer or null".
This commit is contained in:
Daniel Han 2026-05-24 14:10:16 +00:00
commit 08ba6ca0bc

View file

@ -85,6 +85,14 @@ class TestVisionImageSizeCap:
with pytest.raises(ValidationError):
_check_field("vision_image_size", value)
@pytest.mark.parametrize("value", [True, False])
def test_bool_error_says_integer_not_range(self, value):
# Regression guard: pre-fix the bool was coerced to 1/0 and the
# message read "must be in [256, 2048] (got 1)", which was confusing.
with pytest.raises(ValidationError) as exc:
_check_field("vision_image_size", value)
assert "integer or null" in str(exc.value)
class TestLoraRCap:
def test_at_cap_accepts(self):