-
Notifications
You must be signed in to change notification settings - Fork 41
🐛 fix: ensure events only fire when public methods return valid data #181
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
base: dev
Are you sure you want to change the base?
Changes from all commits
85dabda
d7d68c5
fcf31f7
b8e8207
eced9bb
2882c7b
8abf019
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,6 +60,13 @@ | |
| return | ||
| } | ||
|
|
||
| // Validate LoadControlLimitData using EG LPC validator | ||
| // This ensures data integrity and compliance with EG LPC specification requirements | ||
| if err := EGLPCLoadControlLimitValidator.Validate(value); err != nil { | ||
| resultErr = api.ErrDataInvalid | ||
| return | ||
| } | ||
|
|
||
| limit.Value = value.Value.GetValue() | ||
| limit.IsChangeable = (value.IsLimitChangeable != nil && *value.IsLimitChangeable) | ||
| limit.IsActive = (value.IsLimitActive != nil && *value.IsLimitActive) | ||
|
|
@@ -123,6 +130,12 @@ | |
| return 0, api.ErrDataNotAvailable | ||
| } | ||
|
|
||
| // Validate DeviceConfigurationKeyValueData using EG LPC validator | ||
| // This ensures failsafe power limit values are within reasonable ranges and properly formatted | ||
| if err := EGLPCDeviceConfigurationValidator.Validate(data); err != nil { | ||
| return 0, api.ErrDataInvalid | ||
| } | ||
|
|
||
|
Comment on lines
+133
to
+138
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, except that in addition the comment is very misleading. This code doesn't actually check that power limit values are within reasonable limits. It only checks if KeyId is set (which must be set anyway if we've reached this function cal), and if a value is present that only ScaledNumber and/or Duration are set on it (but not String/Boolean/DateTime). I'm not sure of the utility of this, and from a validation standpoint it's not even technically correct since: |
||
| return data.Value.ScaledNumber.GetValue(), nil | ||
| } | ||
|
|
||
|
|
@@ -188,6 +201,7 @@ | |
| return 0, api.ErrDataNotAvailable | ||
| } | ||
|
|
||
|
|
||
| return data.Value.Duration.GetTimeDuration() | ||
| } | ||
|
|
||
|
|
@@ -289,6 +303,12 @@ | |
| return 0, api.ErrDataNotAvailable | ||
| } | ||
|
|
||
| // Validate ElectricalConnectionCharacteristicData using EG LPC validator | ||
| // This ensures nominal consumption values are positive and within reasonable ranges | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it? As far as I can tell, it only validates that a characteristicId is set, and that the characteristicType is reasonable (which it has to be anyway since the filter uses the characterisicType to find the value in the first place. |
||
| if err := EGLPCElectricalConnectionCharacteristicValidator.Validate(&data[0]); err != nil { | ||
| return 0, api.ErrDataInvalid | ||
| } | ||
|
|
||
| return data[0].Value.GetValue(), nil | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does nothing that isn't already done by lines 58-61. It's not technically wrong, it's just dead code that's burning cycles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the intention here to replace the current piecemeal validators with generic validators? In that case this should replace L59-61 and then I'd need to double-check the correctness again.