-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kernelci.api.models: use StrictInt
for version fields
#2382
Conversation
For `int` fields, pydantic internally converts fields to integer if possible e.g. request field value `"2"` is converted to `2` in the FastAPI request handler for model parsing. That's why `KernelVersion.version` is converted to `int` when received by API. Instead of relying on implicit data type conversion for `int` field, use `StrictInt` to enforce defined data type in the request itself. Signed-off-by: Jeny Sadadia <jeny.sadadia@collabora.com>
Causing exception during kci tools use on staging:
|
@nuclearcat that's supposedly related to something in the staging environment using python < 3.10. @pawiecz and @JenySadadia know about this in more detail. Related: #2381 |
As @hardboprobot noted, this indeed looks like Py <= 3.10 issue. @nuclearcat Please provide more details to track down this issue (e.g. command called, exec env - kci-easy?). |
Yes, it can be reproduced also in latest kci-easy during build on debian bullseye. |
|
Right - I'm afraid importing models in helpers used by cli will be a no-go until we drop 3.9 entirely |
Ouch |
True. Now, we are left with 2 options: one is type cast model fields in the tarball service but that is leaking model info. Another option is we can use |
ae84913
to
84fdf46
Compare
Implement `KernelVersion.translate_version_fields` method to translate version string fields to integers. Signed-off-by: Jeny Sadadia <jeny.sadadia@collabora.com>
84fdf46
to
4b64a17
Compare
|
For
int
fields, pydantic internally converts fields to integer if possible e.g. request field value"2"
is converted to2
in the FastAPI request handler for model parsing. That's whyKernelVersion.version
is converted toint
when received by API.Instead of relying on implicit data type conversion for
int
field, useStrictInt
to enforce defined data type in the request itself.