Skip to content

0.8.0-dev6: sanitize whitespace in NATS subject target parts#7

Merged
stevenca merged 1 commit into
mainfrom
fix/0.8.0-dev6-sanitize-subject-whitespace
Jun 2, 2026
Merged

0.8.0-dev6: sanitize whitespace in NATS subject target parts#7
stevenca merged 1 commit into
mainfrom
fix/0.8.0-dev6-sanitize-subject-whitespace

Conversation

@stevenca

@stevenca stevenca commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Summary

Hot-fix to dev5. Caught within ~30 seconds of the dev5 deploy on cpn-ful-netcortex1:

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; NATS subjects must be whitespace-free

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.

  • Subject token: `Port_3`
  • Payload `interface` field: `"Port 3"` (original preserved)

Dots in target parts remain a hard error — they are the NATS token separator and silently splitting would mask a programmer bug.

Test plan

  • CI: all 8 jobs pass
  • Deploy to cpn-ful-netcortex1
  • Within one SNMP poll cycle, verify `snmp.link_state.publish_failed` warnings stop and (if any Meraki MS ports are down) `:ReflexEvent` nodes appear in Neo4j with subjects like `sensory.link_down.snmp_poll.cpn-arlington-ms1|Port_3`

Made with Cursor

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>
@stevenca stevenca merged commit f623e48 into main Jun 2, 2026
8 checks passed
@stevenca stevenca deleted the fix/0.8.0-dev6-sanitize-subject-whitespace branch June 2, 2026 12:50
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