Skip to content

feat: add MQTT message validation per arena-docs spec - #171

Draft
mwfarb with Copilot wants to merge 3 commits into
mainfrom
copilot/add-message-validation
Draft

feat: add MQTT message validation per arena-docs spec#171
mwfarb with Copilot wants to merge 3 commits into
mainfrom
copilot/add-message-validation

Conversation

Copilot AI commented Jul 20, 2026

Copy link
Copy Markdown

Arena-unity was missing all client-side MQTT message validation that arena-web-core already enforces. This adds the missing checks from the message-validation spec to ArenaClientScene.Messaging.cs.

Payload validation (Section 2)

  • Drop empty/null payloads with warning
  • Silently drop invalid JSON
  • Warn and drop if object_id is missing
  • Silently drop if object_id doesn't match topic UUID (position 6) — critical for security in concert with broker ACL

Message envelope validation (Section 3)

  • Warn and drop missing or invalid action (valid: create, update, delete, clientEvent, leave)
  • Warn and drop missing data for create/update actions
  • Warn (continue) on missing type or missing object_type on creates

Self-message filtering (Section 4)

  • Silently skip messages from own userClient (topic position 5) — prevents feedback loops
  • Silently skip messages whose UUID (position 6) matches own camera/hand IDs

Security (Section 6)

  • Block goto-url and textinput clientEvent types from remote clients
  • Only process camera-override and rig messages if addressed to own camera (topic position 7 in localCameraIds)
  • Warn and drop clientEvent where deprecated source field doesn't match topic toUid

Method signature changes

ProcessArenaMessage and ClientEventOnObject now accept an optional string[] topicSplit to carry topic context through the call chain without re-parsing.

Copilot AI linked an issue Jul 20, 2026 that may be closed by this pull request
Copilot AI added 2 commits July 20, 2026 03:03
Implements message validation checks in ArenaClientScene.Messaging.cs:

- Section 2: Payload validation (empty/null, valid JSON, object_id
  present, object_id matches topic UUID)
- Section 3: Message envelope validation (action presence and validity,
  data for create/update, type and object_type warnings)
- Section 4: Self-message filtering (own userClient, own camera/hands)
- Section 6: Security checks (goto-url/textinput blocking, camera-
  override/rig routing to own camera only, clientEvent source validation)

Closes #170
- Wrap JObject.Parse in try-catch for malformed data gracefully
- Wrap JsonConvert.DeserializeObject in try-catch in ClientEventOnObject
- Move clientEvent null data check to ProcessArenaMessage to consolidate
  with create/update data checks, removing redundancy from ClientEventOnObject
Copilot AI changed the title [WIP] Add message validation for MQTT in arena-unity feat: add MQTT message validation per arena-docs spec Jul 20, 2026
Copilot AI requested a review from mwfarb July 20, 2026 03:06
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.

Add Message Validation

2 participants