Skip to content

fix(channels): case-insensitive channel-ID match in find_by_name#609

Open
slvnlrt wants to merge 1 commit into
spacedriveapp:mainfrom
slvnlrt:pr/channel-find-by-name-case
Open

fix(channels): case-insensitive channel-ID match in find_by_name#609
slvnlrt wants to merge 1 commit into
spacedriveapp:mainfrom
slvnlrt:pr/channel-find-by-name-case

Conversation

@slvnlrt

@slvnlrt slvnlrt commented Jun 30, 2026

Copy link
Copy Markdown

ChannelStore::find_by_name lowercases the search query for its display-name matches, but the final channel-ID fallback compares that lowercased query against the raw channel id with a case-sensitive contains:

channels.iter().find(|c| c.id.contains(&name_lower))

Channel ids that contain uppercase characters therefore never match the ID fallback when a target is passed by id — e.g. Microsoft Teams conversation ids like teams:a:1-j_ftWddreoD7cw… (mixed case). This makes send_message_to_another_channel fail with "no channel found" for such channels even though they are listed as available. Numeric / lowercase-id platforms (Discord, Telegram, Slack) are unaffected, which is why it went unnoticed.

Fix: lowercase both sides of the comparison (the query is already lowercased; lowercase the id too).

Surfaced while routing a cross-channel message to a Microsoft Teams DM on a live instance.

Note

Fixes case-insensitive matching for channel IDs in the find_by_name method by lowercasing both sides of the ID comparison. This resolves an issue where mixed-case channel IDs (like Microsoft Teams conversation IDs) would fail to match despite being available, causing cross-channel message routing to fail with "no channel found".

Written by Tembo for commit 04a3c777. This will update automatically on new commits.

The channel-ID fallback lowercased the query but compared it against the
raw (mixed-case) channel id with a case-sensitive contains(), so Teams
conversation ids (which contain uppercase chars) never matched — breaking
send_message_to_another_channel to Teams. Lowercase both sides.
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9f6f1699-2f23-4e83-88cd-301c68daaa8a

📥 Commits

Reviewing files that changed from the base of the PR and between ac52277 and 04a3c77.

📒 Files selected for processing (1)
  • src/conversation/channels.rs

Walkthrough

ChannelStore::find_by_name is updated so the stored channel id is lowercased before the contains check, making channel ID search case-insensitive in both directions.

Changes

Case-insensitive channel ID matching

Layer / File(s) Summary
Lowercase stored id in find_by_name
src/conversation/channels.rs
Applies .to_lowercase() to the stored channel id before the contains comparison against the already-lowercased query term.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: making channel-ID matching case-insensitive in find_by_name.
Description check ✅ Passed The description accurately explains the bug, the cause, and the fix, and matches the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

// already-lowercased query rather than the raw id).
if let Some(channel) = channels
.iter()
.find(|c| c.id.to_lowercase().contains(&name_lower))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor perf note: to_lowercase() does full Unicode case-mapping + allocs. If channel IDs are expected to be ASCII, to_ascii_lowercase() is a bit cheaper here.

Suggested change
.find(|c| c.id.to_lowercase().contains(&name_lower))
.find(|c| c.id.to_ascii_lowercase().contains(&name_lower))

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