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

Fix nil subscription stats to return error #602

Merged
merged 1 commit into from
Nov 14, 2022

Conversation

tomhollingworth
Copy link
Contributor

@tomhollingworth tomhollingworth commented Sep 19, 2022

Fix nil subscription stats to return error

Bug Report

I'm connecting to KepwareEX V6 with v0.3.5 with a number of subscriptions and calling the experimental feature StatsWithContext(ctx). Calling StatsWithContext on a BadNodeId subscription is responding with a StatusOK and a nil *ua.Variant object which then results in a panic as it tries to cast and iterate a slice v.Value().([]*ua.ExtensionObject) see subscription.go line 311.

I expect if the value (v set on subscription.go line 306) is empty, it either returns an error stating such, or returns a nil *ua.SubscriptionDiagnosticsDataType but does not panic.

Fix

Add a nil pointer check before casting and iterating the array, returning an error message if the value is empty.

Review Notes

Is there anywhere to document error messages or a style guide for error messages?

@magiconair magiconair added this to the 0.3.8 milestone Nov 14, 2022
@magiconair magiconair merged commit 2e08acd into gopcua:main Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants