← Back to PRs

#15759: discord: fix sender undefined type errors in message handler

by bniceley50 open 2026-02-13 21:06 View on GitHub →
channel: discord stale size: XS
## Summary - fix TS18048 (`sender` possibly undefined) in Discord message processing - derive `resolvedSender` once via fallback identity when `sender` is absent - use `resolvedSender` for label/name/tag/id and owner allow-list context ## Scope - only `/src/discord/monitor/message-handler.process.ts` - no changes to preflight types/params ## Validation - `pnpm -s lint src/discord/monitor/message-handler.process.ts` - `pnpm -s exec tsc --noEmit` <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This change updates `processDiscordMessage` to stop directly dereferencing `ctx.sender` and instead derive a `resolvedSender` (using `ctx.sender` when present, otherwise a fallback from `resolveDiscordSenderIdentity`). The resolved identity is then used consistently for sender label/name/tag/id and for allow-list context, eliminating TS18048 “possibly undefined” errors while keeping the rest of the message processing and routing flow unchanged. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk. - The change is localized to sender identity dereferencing, uses an existing identity resolver for fallback, and does not alter external interfaces or control flow; no functional regressions were found after tracing preflight sender construction and the identity resolver implementation. - No files require special attention <sub>Last reviewed commit: e8e4dca</sub> <!-- greptile_other_comments_section --> <sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub> <!-- /greptile_comment -->

Most Similar PRs