#22594: fix(mattermost): properly resolve ambiguous target IDs and enable image recognition [AI-assisted]
channel: mattermost
size: S
Cluster:
Mattermost Mention Overrides Fixes
## Summary
This PR contains two fixes for the Mattermost integration:
1. **Properly resolve ambiguous target IDs via graceful fallback** - Fixes an issue where 26-character user IDs without a prefix were incorrectly assumed to be channel IDs, leading to 403 Forbidden errors.
2. **Enable image recognition with SSRF policy** - Adds SSRF policy configuration to allow fetching media files from the Mattermost server hostname, enabling proper image recognition.
## Changes
### Target ID Resolution
- Changed `normalizeMattermostMessagingTarget` to return unprefixed IDs as-is instead of auto-adding `channel:` prefix
- Added `kind: "unknown"` target type to represent ambiguous IDs
- Modified `parseMattermostTarget` to classify unprefixed IDs as "unknown" instead of "channel"
- Implemented try-catch fallback in `resolveTargetChannelId` to probe channel existence before falling back to user ID resolution
### Image Recognition Support
- Added `ssrfPolicy` parameter with allowed hostname when fetching media files
- Enables the monitor to properly download and recognize images from Mattermost server
## Testing
- Tested locally with Mattermost instance
- Verified ambiguous IDs (users/channels) are correctly resolved
- Verified image recognition now works correctly with the SSRF policy in place
- Both fixes have been validated in a real Mattermost environment
## AI-Assisted Note
- [x] Mark as AI-assisted
- [x] Fully tested
- [x] Code reviewed and understood by contributor
- AI tool used: Claude Sonnet 4.6
## What & Why
### Target ID Resolution
The Mattermost plugin was incorrectly treating all 26-character unprefixed IDs as channel IDs. This caused 403 errors when users tried to interact with direct message channels using user IDs. The fix implements a graceful fallback pattern that probes the ID type and falls back appropriately.
### Image Recognition Support
The Mattermost monitor was unable to fetch images due to missing SSRF policy. This fix adds the required `ssrfPolicy` configuration to allow downloading media files from the configured Mattermost server hostname, which is essential for image recognition features.
Both fixes work together to provide a complete and robust Mattermost integration experience.
Most Similar PRs
#10394: feat(mattermost): add image attachment support for inbound messages
by mithril-logic · 2026-02-06
70.9%
#11086: fix(mattermost): allow private network for inbound media download
by oskarmodig · 2026-02-07
68.3%
#18716: msteams: fix DM image delivery + user target routing
by ktsushilofficial · 2026-02-17
67.4%
#10081: fix(mattermost): pass requireMentionOverride to core resolver
by manchmod · 2026-02-06
65.3%
#10027: Mattermost: fix attachment downloads (GET + private-network hosts)
by transportrefer · 2026-02-06
65.2%
#13089: fix(msteams): alias team config under channel conversation IDs for ...
by BradGroux · 2026-02-10
65.0%
#23723: feat(message): improve send param ergonomics and actionable routing...
by SmithLabsLLC · 2026-02-22
64.9%
#19274: feat(mattermost): enable threaded replies in channels
by rockinyp · 2026-02-17
64.2%
#20928: mattermost: add readMessages action for channel history
by hubertusgbecker · 2026-02-19
64.0%
#8648: fix: don't treat bare numeric Discord IDs as definitive target IDs
by dbottme · 2026-02-04
63.8%