Skip to content

fix(validate): reject non-integer values in integer-typed fields - #136

Merged
Seungpyo1007 merged 1 commit into
mainfrom
fix/validate-integer-fields
Nov 13, 2026
Merged

Seungpyo1007 merged 1 commit into
mainfrom
fix/validate-integer-fields

Conversation

@TechEngineBot

Copy link
Copy Markdown
Member

What & why

Part of #98. A CPU record with tdp_w: 11.5 passed validation and only failed later, when the dump built the read schema, because the API types the field as an integer. The validator now rejects fractional numbers, booleans and strings in every field the models type as an integer, so the dataset's PR checks catch it before a dump does.

Changes

  • app/validate.py: explicit sets of integer fields per category, next to the required-field sets, and one shared check. Whole floats such as 65.0 stay valid: the serialiser accepts them and 15 existing CPU records hold one. The device catalog's own integer check is replaced by the shared one.
  • Standard library only: the validator still imports nothing outside the standard library, app.categories and app.data_root. TechAPI's PR checks run it from the submodule without installing the engine, so this matters. A unit test imports it in a subprocess with -I -S.
  • Tests: a test derives the integer fields from the models and fails when a model gains an integer column the validator's sets lack; another checks that no read schema types a field as an integer unless the model does.

Checks

  • Full TechAPI dataset with the system Python and nothing installed: passes, zero errors, run time unchanged (about 25 s).
  • ruff, mypy app, pytest tests/unit (698 passed) locally.

A CPU record with tdp_w 11.5 passed validation and only failed in the
dump, where the read schema types the field as an integer. The validator
now lists the integer fields of each category and reports a fractional
number, a boolean or a string in any of them, and does the same for the
members of list-of-integer fields.

The lists are written out next to the required-field sets so the module
still imports with the standard library alone; TechAPI's PR checks run it
without installing the engine. A unit test derives the same lists from
the models and fails when the two disagree, and another imports the
validator with site-packages off the path.

Whole floats such as 65.0 stay valid: the read schemas load them as
integers and 15 CPU records hold one. The device catalog's own integer
check is replaced by the shared one.
@TechEngineBot TechEngineBot added bug Something isn't working enhancement New feature or request labels Nov 13, 2026
@Seungpyo1007
Seungpyo1007 merged commit c0743ba into main Nov 13, 2026
5 checks passed
@Seungpyo1007
Seungpyo1007 deleted the fix/validate-integer-fields branch November 13, 2026 15:52
@github-project-automation github-project-automation Bot moved this from Todo to Done in TechAPI-Project Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants