← Back to PRs

#22594: fix(mattermost): properly resolve ambiguous target IDs and enable image recognition [AI-assisted]

by webclerk open 2026-02-21 10:48 View on GitHub →
channel: mattermost size: S
## 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