0.8.0-dev6: sanitize whitespace in NATS subject target parts#7
Merged
Merged
Conversation
Hot-fix to dev5, caught seconds after the dev5 deploy on cpn-ful-netcortex1.
Meraki MS switches expose interface names like 'Port 3' / 'Port 4' with
literal spaces. NATS forbids whitespace in subjects, so the publisher's
validator (correctly) rejected every such event, dropping link-state
events for every Meraki MS port:
snmp.link_state.publish_failed device=cpn-arlington-ms1 interface=Port 3
error=sensory subject target part 0='cpn-arlington-ms1|Port 3'
contains whitespace
The fix collapses any whitespace run in each target part to a single '_'
at the SensoryPublisher boundary, so every future publisher (Meraki
webhook, SNMP trap, gNMI dial-out) inherits the behavior without each
one re-implementing it. The original identifier is preserved verbatim
in the payload's interface/device/target fields, so consumers that need
the human-readable name still have it.
Dots in target parts remain a hard error — they are the NATS token
separator and silently splitting would mask a programmer bug.
Tests: 3 new cases (sanitization, multi-run collapse, dots-still-reject).
Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
Hot-fix to dev5. Caught within ~30 seconds of the dev5 deploy on
cpn-ful-netcortex1:Meraki MS switches expose interface names like `"Port 3"`, `"Port 4"` with literal spaces. NATS subjects forbid whitespace, so the publisher's validator (correctly) rejected every such event — dropping link-state events for every Meraki MS port on every poll cycle.
Fix
Collapse any whitespace run in each target part to a single `_` at the `SensoryPublisher` boundary. Every future publisher (Meraki webhook in next dev cycle, SNMP traps, gNMI dial-out) inherits the behavior automatically.
Dots in target parts remain a hard error — they are the NATS token separator and silently splitting would mask a programmer bug.
Test plan
Made with Cursor