Pydantic validation for the v1.2 API#53
Open
Yannicked wants to merge 9 commits intoiterorganization:developfrom
Open
Pydantic validation for the v1.2 API#53Yannicked wants to merge 9 commits intoiterorganization:developfrom
Yannicked wants to merge 9 commits intoiterorganization:developfrom
Conversation
deepakmaroo
reviewed
Mar 13, 2026
Contributor
deepakmaroo
left a comment
There was a problem hiding this comment.
There is exception when Dashboard request for list of simulations
127.0.0.1 - - [13/Mar/2026 09:50:27] "OPTIONS /v1.2/simulations?code.name=&status=&uploaded_by= HTTP/1.1" 200 -
Unhandled exception in SimulationList.get
Traceback (most recent call last):
File "/home/ITER/marood/Desktop/redhat-workspace/testing/SimDB_Test/src/simdb/remote/core/pydantic_utils.py", line 287, in wrapper
result = f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File "/home/ITER/marood/Desktop/redhat-workspace/testing/SimDB_Test/src/simdb/remote/apis/v1_2/simulations.py", line 206, in get
return PaginatedResponse[SimulationListItem].model_validate(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ITER/marood/Desktop/redhat-workspace/testing/SimDB_Test/venv/lib/python3.11/site-packages/pydantic/main.py", line 716, in model_validate
return cls.__pydantic_validator__.validate_python(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for PaginatedResponse[SimulationListItem]
count
Input should be a valid integer, got a number with a fractional part [type=int_from_float, input_value=110.66666666666667, input_type=float]
For further information visit https://errors.pydantic.dev/2.12/v/int_from_float
127.0.0.1 - - [13/Mar/2026 09:50:27] "GET /v1.2/simulations?code.name=&status=&uploaded_by= HTTP/1.1" 500 -
No sure if below error occurred due to local database migration applied
(venv) [marood@98dci4-srv-1002 SimDB_Test]$ simdb --debug remote sdcc list -l 10
Error: Corrupted data - non-optional metadata is None.
Traceback (most recent call last):
File "/home/ITER/marood/Desktop/redhat-workspace/testing/SimDB_Test/venv/bin/simdb", line 10, in <module>
sys.exit(main())
File "/home/ITER/marood/Desktop/redhat-workspace/testing/SimDB_Test/src/simdb/cli/remote_api.py", line 584, in list_simulations
return [Simulation.from_data(sim) for sim in data["results"]]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ITER/marood/Desktop/redhat-workspace/testing/SimDB_Test/src/simdb/cli/remote_api.py", line 584, in <listcomp>
return [Simulation.from_data(sim) for sim in data["results"]]
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ITER/marood/Desktop/redhat-workspace/testing/SimDB_Test/src/simdb/database/models/simulation.py", line 340, in from_data
metadata = checked_get(data, "metadata", list)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ITER/marood/Desktop/redhat-workspace/testing/SimDB_Test/src/simdb/database/models/utils.py", line 69, in checked_get
raise ValueError(f"Corrupted data - non-optional {key} is None.")
ValueError: Corrupted data - non-optional metadata is None.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces a
@pydantic_validatedecorator that wires up typed request/response handling for all v1.2 API endpoints, replacing the previous mix of manualjsonify,try/except DatabaseError, and ad-hoc error returns.This also automatically adds the expected request and response data to the autogenerated swagger API docs:
