Skip to content

Telegram reply context: missing type guard causes [object Object] in message content #27201

@p3nchan

Description

@p3nchan

Bug Description

When processing Telegram reply contexts, describeReplyTarget() in the send handler lacks a typeof check on replyLike.text / replyLike.caption, causing [object Object] to appear in the delivered message content.

Location

dist/send-Bwxyans7.js line ~508:

body = (replyLike.text ?? replyLike.caption ?? "").trim();

If replyLike.text or replyLike.caption is not a string (e.g., an object from a Telegram API edge case), JavaScript coerces it to [object Object].

Contrast with existing pattern

Elsewhere in the same codebase, proper type guards are used:

const text = typeof msg.text === "string" ? msg.text : void 0; // ✅

The reply context path is missing this protection. ❌

Steps to Reproduce

  1. Run OpenClaw with Telegram channel configured
  2. Receive a message that is a reply to another message
  3. If the replied-to message's text or caption field is not a plain string (Telegram API edge case), the agent receives [object Object] instead of actual content

Expected Behavior

Reply context should apply typeof === "string" guard before using text/caption, falling back gracefully if the value is not a string.

Suggested Fix

const rawText = replyLike.text ?? replyLike.caption ?? "";
body = (typeof rawText === "string" ? rawText : "").trim();

Environment

  • OpenClaw latest (npm)
  • Telegram channel
  • macOS / Node v24

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions