Skip to content
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

Fixes: #18038 - Ensure DeviceType._abs_weight is stored as an integer #18039

Merged
merged 2 commits into from
Nov 20, 2024

Conversation

bctiemann
Copy link
Contributor

@bctiemann bctiemann commented Nov 18, 2024

Fixes: #18038

WeightMixin provides an _abs_weight field which stores the normalized weight in grams. It is a PositiveBigIntegerField, yet the value stored in it is the unvalidated output of to_grams, which may be a float. This does not normally cause issues in the app, but in the case of netbox-branching, the field validation fails when the field value is synced from one branch to another because it expects an integer but receives a float.

This fix adds type annotation and consistent return values to to_grams.

netbox/utilities/conversion.py Outdated Show resolved Hide resolved
netbox/utilities/conversion.py Outdated Show resolved Hide resolved
@jeremystretch jeremystretch merged commit e36f23e into develop Nov 20, 2024
5 of 6 checks passed
@jeremystretch jeremystretch deleted the 162-store-_abs_weight-as-int branch November 20, 2024 19:33
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DeviceType._abs_weight being stored as float value though it is a PositiveBigIntegerField
2 participants