fix(matrix): preserve room ID casing in directory resolution (#19278)#19304
fix(matrix): preserve room ID casing in directory resolution (#19278)#19304lailoo wants to merge 1 commit intoopenclaw:mainfrom
Conversation
nikolasdehor
left a comment
There was a problem hiding this comment.
Well-scoped fix for a real bug. Matrix room IDs (!AbCdEf:server) and aliases (#Room:server) are case-sensitive, but normalizeQuery() was lowercasing them, breaking per-room config lookups.
Review
- Correct fix — Uses
trim()instead ofnormalizeQuery()for structured identifiers (!-prefixed room IDs and#-prefixed aliases). Lowercasing is only applied for the fuzzy room-name search path where case-insensitive matching is appropriate. - Minimal change — The logic change is narrow: structured ID lookup preserves casing, fuzzy name search normalizes casing. This matches how Matrix identifiers actually work.
- Good test coverage — Three regression tests covering room ID, alias, and mixed-case scenarios. All 37 existing matrix tests pass.
- Changelog entry included — Good practice.
LGTM, merge-ready. Fixes #19278.
|
This could be relevant to what you're working on. Several other PRs seem to address the same problem:
Both PRs fix issue #19278: Matrix per-room config (requireMention, autoReply) is silently ignored because room IDs are lowercased during config resolution but compared in original case at runtime, causing lookup failures. Both approaches have merit — might be worth coordinating. If any of these links don't look right, let me know and I'll correct them. |
|
This pull request has been automatically marked as stale due to inactivity. |
Summary
normalizeQuery()indirectory-live.tslowercases room IDs/aliases before returning them, butresolveChannelEntryMatch()performs exact-case lookup at runtime!-prefixed room IDs and#-prefixed aliases; only lowercase for fuzzy name searchFixes #19278
Problem
When a user configures a Matrix room by its room ID (e.g.
!ArAQdbw5b42R5uBHuWz84xs6GI:matrix.org), the directory resolution step inlistMatrixDirectoryGroupsLive()passes the query throughnormalizeQuery()which calls.toLowerCase(). The lowercased ID becomes the key in the internalroomsConfigmap.At runtime, Matrix events arrive with the original-case room ID.
resolveMatrixRoomConfig()builds lookup candidates using this original-case ID and callsresolveChannelEntryMatch(), which usesObject.prototype.hasOwnProperty.call(entries, key)— an exact-case match. The lookup fails because!araqdbw5...≠!ArAQdbw5....Before fix:
Changes
extensions/matrix/src/directory-live.ts— Usetrim()instead ofnormalizeQuery()for the!and#code paths, preserving original casing. Only applytoLowerCase()for the fuzzy room-name search path where case-insensitive comparison is needed.extensions/matrix/src/directory-live.test.ts— Add regression tests for room ID case preservation, alias case preservation, and fuzzy search lowercasing.CHANGELOG.md— Add fix entry.After fix:
Test plan
!-prefixed room ID#-prefixed aliasEffect on User Experience
Before: Per-room settings like
requireMention: falseandautoReply: trueare silently ignored for Matrix rooms configured by room ID. The bot requires a mention even when configured not to.After: Per-room settings are applied correctly regardless of room ID casing.