hermes - ✅(Solved) Fix bug(gateway): DeliveryTarget.parse corrupts explicit chat IDs and Matrix room targets [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#11768Fetched 2026-04-18 05:58:58
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
cross-referenced ×2referenced ×1

Root Cause

Expected Behavior

  • Only the platform name should be normalized.
  • Explicit chat_id / thread_id values should be preserved verbatim.
  • Matrix-style IDs should not be split incorrectly just because they contain :.

Fix Action

Fixed

PR fix notes

PR #11893: fix(gateway): preserve case-sensitive chat IDs in DeliveryTarget.parse

Description (problem / solution / changelog)

Summary

Fixes issue #11768 where DeliveryTarget.parse() was lowercasing the entire target string, corrupting case-sensitive chat IDs like Slack C123ABC.

Root Cause

The original code used target.strip().lower() on the entire target string before splitting. This caused:

  1. Slack channel IDs like C123ABC to become c123abc (Slack IDs are case-sensitive)
  2. Any mixed-case chat ID to lose its original case

Fix

  • Only lowercase the platform prefix for case-insensitive matching
  • Preserve the original case for chat_id and thread_id values
  • Platform names remain case-insensitive (e.g., TELEGRAM, Telegram, telegram all work)

Test Plan

  • Added regression tests for case-sensitive chat ID parsing
  • Verified Slack uppercase IDs are preserved
  • Verified mixed-case chat IDs survive roundtrip
  • Verified platform names remain case-insensitive
  • All existing tests pass

Closes NousResearch/hermes-agent#11768

Changed files

  • gateway/delivery.py (modified, +9/-7)
  • tests/gateway/test_delivery.py (modified, +58/-0)

Code Example

from gateway.delivery import DeliveryTarget

print(DeliveryTarget.parse('slack:C123ABC'))
# actual chat_id: 'c123abc'

print(DeliveryTarget.parse('matrix:!RoomABC:example.org'))
# actual chat_id: '!roomabc'
# actual thread_id: 'example.org'
RAW_BUFFERClick to expand / collapse

Bug Description

DeliveryTarget.parse() lowercases the entire explicit target string and then splits on : at most twice. That corrupts case-sensitive chat IDs (for example Slack channel/thread IDs) and also misparses chat IDs that themselves contain colons (for example Matrix room IDs like !RoomABC:example.org).

Affected Files / Lines

  • gateway/delivery.py:56
  • gateway/delivery.py:73-81

Why this is a bug

  • target.strip().lower() changes explicit IDs supplied by the caller.
  • target.split(":", 2) assumes only the platform prefix uses :, but Matrix identifiers also contain :.

Minimal Reproduction

from gateway.delivery import DeliveryTarget

print(DeliveryTarget.parse('slack:C123ABC'))
# actual chat_id: 'c123abc'

print(DeliveryTarget.parse('matrix:!RoomABC:example.org'))
# actual chat_id: '!roomabc'
# actual thread_id: 'example.org'

Observed in repo environment:

  • DeliveryTarget.parse('slack:C123ABC').chat_id == 'c123abc'
  • DeliveryTarget.parse('matrix:!RoomABC:example.org') returns chat_id='!roomabc', thread_id='example.org'

Expected Behavior

  • Only the platform name should be normalized.
  • Explicit chat_id / thread_id values should be preserved verbatim.
  • Matrix-style IDs should not be split incorrectly just because they contain :.

Actual Behavior

  • Explicit IDs are lowercased.
  • Matrix room IDs are split into chat_id + thread_id incorrectly.

Suggested Investigation Direction

  • Parse only the platform prefix case-insensitively.
  • Preserve the remainder of the target string exactly as provided.
  • Consider a less ambiguous encoding for optional thread_id, or split from the left only once and handle platform-specific parsing afterward.

extent analysis

TL;DR

Modify the DeliveryTarget.parse() function to case-insensitively parse only the platform prefix and preserve the remainder of the target string.

Guidance

  • Identify the platform prefix in the target string and normalize it case-insensitively, while keeping the rest of the string unchanged.
  • Consider using a more robust parsing approach, such as splitting the string from the left only once, to handle platform-specific parsing and avoid incorrect splitting of Matrix room IDs.
  • Review the encoding of optional thread_id to prevent ambiguity and ensure correct parsing.
  • Test the modified parse() function with various input scenarios, including Slack and Matrix IDs, to ensure correct behavior.

Example

def parse(target):
    # Split the target string into platform prefix and the rest
    parts = target.split(":", 1)
    platform = parts[0].lower()
    # Preserve the rest of the target string
    id_string = ":".join(parts[1:]) if len(parts) > 1 else ""
    # Handle platform-specific parsing
    if platform == "matrix":
        # Matrix-specific parsing logic
        pass
    # ...

Notes

The suggested changes aim to address the issue by preserving the case and content of the explicit IDs and correctly handling Matrix room IDs. However, the exact implementation details may vary depending on the specific requirements and constraints of the DeliveryTarget.parse() function.

Recommendation

Apply a workaround by modifying the DeliveryTarget.parse() function to correctly handle platform prefixes and IDs, as the current implementation has significant flaws that need to be addressed to ensure correct behavior.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix bug(gateway): DeliveryTarget.parse corrupts explicit chat IDs and Matrix room targets [1 pull requests, 1 participants]