Skip to content

feat(edge): check group, node and device IDs before connecting (v0.7.0) - #41

Merged
boeboe merged 1 commit into
mainfrom
feat/v0.7.0
Nov 16, 2026
Merged

boeboe merged 1 commit into
mainfrom
feat/v0.7.0

Conversation

@boeboe

@boeboe boeboe commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

sparkplugbctl edge now checks --group, --node and every --device value 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 --device with 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.
  • README.md, docs/exitcodes.md (row 3), RELEASE.md.

Tests: TestEdgeChecksIDsBeforeConnect is 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 --device case fails with exit 4 after a Connect; the group and node cases fail on the message only. make check, make e2e and go test -race ./... pass.

listen --device is unchanged: listen does not validate its filters.

Checked again by the coordinator: gofmt -l . empty, go vet ./..., go test -race ./... and bin/verify.sh sparkplugbctl (policy compliant, docs ok, build and vet ok).

This implements the follow-up the maintainer asked for: edge --device checked at start-up.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@boeboe
boeboe merged commit 9b52f21 into main Nov 16, 2026
14 checks passed
@boeboe
boeboe deleted the feat/v0.7.0 branch November 16, 2026 14:14
@codecov

codecov Bot commented Nov 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

1 participant