#9757: fix(signal): exclude "unknown" media kind from placeholder generation
channel: imessage
channel: signal
stale
Cluster:
Signal Plugin Enhancements
Fixes #9706
## Problem
`mediaKindFromMime(mime?: string | null)` returns `"unknown"` (a truthy string) when MIME type is undefined/null/empty. Code checking `if (kind)` incorrectly treats `"unknown"` as valid, generating `<media:unknown>` placeholder.
### Root cause from issue #9706
Two separate problems:
1. **Zombie signal-cli processes** - compete for SSE events, causing corrupted/empty envelopes (process management issue - not addressed in this PR)
2. **Truthy "unknown" check** - `"unknown"` string passes `if (kind)` check → **this PR fixes this**
## Solution
Added `kind !== "unknown"` guard to all 4 locations that generate `<media:${kind}>` placeholder:
### Inbound (receiving messages from users)
| File | Line | Before | After |
|------|------|--------|-------|
| `src/signal/monitor/event-handler.ts` | 526 | `if (kind)` | `if (kind && kind !== "unknown")` |
| `src/imessage/monitor/monitor-provider.ts` | 417 | `if (kind)` | `if (kind && kind !== "unknown")` |
**Behavior change:** Corrupted envelopes (empty `messageText`, no attachments, unknown MIME) are now **ignored** instead of processed as `<media:unknown>`. When attachments exist but MIME is unknown, fallback is `<media:attachment>`.
### Outbound (bot sending messages)
| File | Line | Before | After |
|------|------|--------|-------|
| `src/signal/send.ts` | 167 | `if (!message && kind)` | `if (!message && kind && kind !== "unknown")` |
| `src/imessage/send.ts` | 88 | `if (kind)` | `if (kind && kind !== "unknown")` |
**Behavior change:** Attachments with unknown MIME type are sent **without** ugly `<media:unknown>` caption. Signal/iMessage display attachment cleanly without text.
## Testing
- Unit tests added for `mediaKindFromMime` covering the truthy `"unknown"` edge case
- Verified Signal API accepts attachments without message body (caption is optional)
- Checked other channels: Mattermost already handles `"unknown"` → `"document"`, Matrix uses switch with default case
## Architectural note
A cleaner long-term fix would be changing `mediaKindFromMime` to return `undefined` instead of `"unknown"`, fixing all call sites at once. However, this PR takes a surgical approach with minimal blast radius. The refactor can be done separately if desired.
## Not addressed
The **zombie signal-cli process** issue mentioned in #9706 is a separate process management problem. This PR only fixes the placeholder logic. If zombie processes still cause empty envelopes, they will now be **silently ignored** (correct behavior) instead of generating `<media:unknown>` responses.
lobster-biscuit
Most Similar PRs
#15770: fix: prevent phantom <media:unknown> messages from Signal protocol ...
by joetomasone · 2026-02-13
84.3%
#22540: fix(signal): preserve original filename in outbound attachments
by lailoo · 2026-02-21
71.4%
#6591: fix(signal): process all inbound attachments in parallel
by ProofOfReach · 2026-02-01
68.1%
#15956: feat(signal): enhanced inbound message handling
by heyhudson · 2026-02-14
67.4%
#11990: Fix media understanding file path suppression + image tool bare-ID ...
by robertbergman2 · 2026-02-08
67.4%
#11160: Media: add missing audio MIME-to-extension mappings (aac, flac, opu...
by lailoo · 2026-02-07
66.6%
#15914: feat: add messages.suppressMediaPlaceholders config option
by Shuai-DaiDai · 2026-02-14
66.0%
#8014: fix(media-understanding): support legacy {file} placeholder in CLI ...
by Glucksberg · 2026-02-03
65.2%
#14057: feat(telegram): add ignoreMediaTypes config to skip specific inboun...
by pavelsamoylenko · 2026-02-11
64.9%
#21586: fix: support multiple --media flags in send command
by mattemoon · 2026-02-20
64.9%