Skip to content

Refuse a whole-number float in an integer field at config validate - #603

Merged
shipmill-romamo[bot] merged 5 commits into
mainfrom
fix/602-strict-integer
Nov 24, 2026
Merged

shipmill-romamo[bot] merged 5 commits into
mainfrom
fix/602-strict-integer

Conversation

@shipmill-romamo

@shipmill-romamo shipmill-romamo Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Plan

  • Serves: quality bar (Q-1)
  • Files: sdk/tests/test_strict_integer.py (new), sdk/src/cloudfall/validation.py, changelog.d/602-strict-integer.md; review fix: sdk/src/cloudfall/domain.py, sdk/tests/test_retain_releases.py
  • Order: commit the failing regression test alone first (a whole-number float in spec.proxy.upstream.port and in spec.proxy.maxRequestBodyMegabytes is refused by config validate with its field path; plain integers still pass; true is still refused); then build SchemaCatalog's validators from a Draft202012Validator extended with a strict integer type checker, with its changelog fragment
  • Proof: uv run pytest sdk/tests/test_strict_integer.py fails on main and passes with the fix; sdk/tests/test_validation.py, sdk/tests/test_domain_request_body_limit.py and the other validation tests stay green; uv run cloudfall config validate --project config/examples passes
  • Kind: fix
  • Tests changed: sdk/tests/test_retain_releases.py: it asserted that retainReleases: 2.0 validates and reads as 2, the one integer field that coerced a whole-number float; under this change 2.0 is refused like every other integer field, so its cases move from the accepted to the refused lists

Summary

SchemaCatalog built a stock Draft202012Validator, whose integer type accepts a float with a zero fractional part. A Domain with spec.proxy.upstream.port: 8100.0 passed cloudfall config validate, then the value object (_required_bounded_integer) raised TypeError and the command that read it, such as cloudfall domains apply, failed with HANDLER_CRASHED.

The catalog now builds its validators from jsonschema.validators.extend(Draft202012Validator, type_checker=...), whose integer accepts only a Python int and still refuses bool. Every integer field of every schema refuses 8100.0 at config validate, reported as schema_validation_failed with the field's path, like any other schema error. check_schema still checks each schema against the 2020-12 metaschema, and $refs resolve through the same strict validator class. The value objects' TypeError stays as the second line of defence.

Behaviour change: a project that writes a whole-number float in any integer field now fails config validate. For every field but one, such a value passed and then crashed the command that read it. The exception is a Component's spec.deployment.retainReleases: RetainReleases.from_boundary turned 2.0 into 2, so retainReleases: 2.0 validated and worked on main. It is now refused like the rest, and the value object no longer coerces it (review fix). No example or fixture writes an integer as a float.

The changelog entry is under ### Breaking, as D-14 requires for a change after which a config that validated before stops validating, and names retainReleases and the step a user takes before upgrading.

Test notes

  • New: sdk/tests/test_strict_integer.py, failing on main, passing here
  • Changed in review: sdk/tests/test_retain_releases.py, where 2.0 joins the refused values and the value object's refused list (the latter fails on the old coercion)
  • Ran locally: uv run ruff check ., uv run mypy, uv run cloudfall config validate --project config/examples, and the validation and retain-releases test files; the full suite is left to CI

Fixes #602

🤖 Generated with Claude Code

shipmill-romamo Bot and others added 3 commits November 23, 2026 22:07
A Domain with spec.proxy.upstream.port: 8100.0 (or
maxRequestBodyMegabytes: 55.0) passes config validate today, then the
value object raises TypeError in the command that reads it. These tests
fail until the schema validator's integer type refuses floats.

Part of #602

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The schema catalog built a stock Draft202012Validator, whose integer type
accepts 8100.0. Such a value passed config validate, then the value
object raised TypeError and the command that read it crashed. The
catalog's validators now use a 2020-12 validator whose integer accepts
only a Python int (still refusing bool), so the error is a schema error
with the field's path. The value objects' TypeError stays as the second
line of defence.

Fixes #602

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A config that wrote an integer as a whole-number float validated before
and now fails config validate, so D-14 puts the entry under Breaking,
with the step a user takes before upgrading.

Part of #602

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

Copy link
Copy Markdown
Contributor Author

@romamo Decided without waiting: config validate now refuses a whole-number float such as 8100.0 in any integer field, and the changelog lists it under Breaking with the step to take before upgrading.

Why: Q-1 says a config that validates must not crash a later command, and every such value in a field read through a value object already crashed with TypeError (#602). D-14 puts any change that makes a validating config stop validating under ### Breaking, so the entry follows it; [bump] then reads it as a major bump, and the release lane asks about the breaking release as usual.
Not taken: listing it under Fixed. That departs from D-14 and needs your answer, on the grounds that such configs never worked anyway.

Reply with a comment starting with veto before 2026-11-24 20:15 UTC to reverse it, adding what you want instead if you like. A later veto still counts and gets a follow-up.

shipmill-romamo Bot and others added 2 commits November 24, 2026 06:41
RetainReleases.from_boundary coerced an integral float such as 2.0 to an
int, because the stock JSON Schema integer let it through validation. With
the strict integer type checker (#602), 2.0 no longer validates, so the
coercion is dead and the value object now refuses it with TypeError like
the other integer value objects. The 2.0 and 5.0 cases move from the
inventory test to the refused values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
spec.deployment.retainReleases: 2.0 validated and read as 2 before #602;
it is the one integer field where a whole-number float worked, so the
entry names it as the value to fix before upgrading.

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

@shipmill-romamo shipmill-romamo Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of #603 at 7015bf1: MERGE AFTER SMALL FIX

Both CI jobs failed on sdk/tests/test_retain_releases.py::test_the_inventory_carries_the_count_five_when_absent[2.0-2] and [5.0-5]. The failure comes from this PR. On main, retainReleases: 2.0 validated and read as 2 on purpose (RetainReleases.from_boundary coerced a whole-number float). So the decided comment's premise, that every such value already crashed, doesn't hold for this one field: a config with retainReleases: 2.0 worked before and now stops validating. That still falls inside the decision ("any integer field", listed under Breaking, Q-3), so the review brings the code in line instead of exempting the field.

Fixes pushed:

  • 0054ce0: sdk/src/cloudfall/domain.py RetainReleases.from_boundary no longer coerces an integral float; sdk/tests/test_retain_releases.py moves 2.0 to the refused cases and the value object's refused list, which fails on the old coercion
  • 7015bf1: changelog.d/602-strict-integer.md names spec.deployment.retainReleases as the one field where 2.0 used to work, with its upgrade step

Checks: rebase onto main was a no-op; changelog_guard.py check exits 0; ruff check, mypy, config validate --project config/examples pass; the strict-integer, retain-releases, validation and request-body-limit tests pass (87). The full suite runs in CI.

Test proof: PROVEN (fix).

Not fixed (nits):

  • F-1 sdk/src/cloudfall/investigation.py:727 checks tool arguments with the stock Draft202012Validator; no tool schema has an integer today, so nothing reads differently
  • F-2 the plan's Tests changed: line now names sdk/tests/test_retain_releases.py with its reason
  • F-3 ruff format --check already fails across the repo on main; CI doesn't run it

History: H-2 consistent (a Breaking entry for a config that stops validating); H-1, H-3 to H-7 unrelated.

@shipmill-romamo
shipmill-romamo Bot merged commit ead3c4a into main Nov 24, 2026
3 checks passed
@shipmill-romamo
shipmill-romamo Bot deleted the fix/602-strict-integer branch November 24, 2026 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

decided An agent decided at notify; the maintainer may veto

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A whole-number float in an integer field passes config validate, then crashes the command that reads it

0 participants