Repository navigation
feat(edge): check group, node and device IDs before connecting (v0.7.0) - #41
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
sparkplugbctl edgenow checks--group,--nodeand every--devicevalue when it starts, before it connects. A value that cannot be a segment of a Sparkplug topic ends the command with exit 3 (invalid_input). Such a value is empty, not valid UTF-8, or has/,+or#(Sparkplug B 3.0.0, tck-id-topics-device-id). The message names the flag and the quoted value, for example--device "a/b": a Sparkplug ID is non-empty valid UTF-8 without '/', '+' or '#'.The check is go-sparkplugb's own rule. The topic package exports no check of a single ID, so the ID is parsed as the last segment of a STATE topic, as go-sparkplugb's edge package does.
Why: in v0.6.2 a refused device ID was passed on unchecked. The node connected, published NBIRTH and reported the failed DBIRTH on stderr. It skipped that device and the ones after it, and went on publishing NDATA. A refused group or node ID was already stopped before connecting with exit 3, and still is; its message now names the flag.
Breaking (RELEASE.md):
edge --devicewith such a value now exits 3 at once, before connecting (before: it connected and ran on). Restore path: none sensible; use IDs the rule allows.Files:
cmd/edge.go: the check and the flag help.cmd/validate_test.go:TestEdgeChecksIDsBeforeConnect.cmd/rectransport_test.go:connectErr.Tests:
TestEdgeChecksIDsBeforeConnectis a table of 32 boundaries for the three flags. It covers empty, one character,/,+and#alone and inside, invalid UTF-8, a control character, a refused second device, and accepted IDs. It checks the exit code, the message, and that the transport sees no Connect for a refused value. On v0.6.2 every refused--devicecase fails with exit 4 after a Connect; the group and node cases fail on the message only.make check,make e2eandgo test -race ./...pass.listen --deviceis unchanged:listendoes not validate its filters.Checked again by the coordinator:
gofmt -l .empty,go vet ./...,go test -race ./...andbin/verify.sh sparkplugbctl(policy compliant, docs ok, build and vet ok).This implements the follow-up the maintainer asked for:
edge --devicechecked at start-up.🤖 Generated with Claude Code