Skip to content

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.

@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

3 participants