Skip to content

Bug: Plugin crashes with TypeError in processImage when handling native photo uploads #23

@GarrickBrown

Description

@GarrickBrown

Issue Report for elizaos-plugins/plugin-telegram

1. Describe the bug
The @elizaos/plugin-telegram crashes when a user uploads an image "as a photo" via the Telegram client (as opposed to sending it "as a file"). The internal processImage function within the plugin's messageManager.ts calls runtime.useModel(ModelType.IMAGE_DESCRIPTION, ...) with incorrect parameters. It passes a raw string (imageUrl) as the second argument, but the useModel function for IMAGE_DESCRIPTION expects an object (ImageDescriptionParams). This results in a TypeError: paramsObj is not an Object. which halts all further message processing.

2. To Reproduce
Steps to reproduce the behavior:

  1. Set up an ElizaOS project with @elizaos/plugin-telegram.
  2. Ensure a model provider that can handle ModelType.IMAGE_DESCRIPTION is configured (e.g., @elizaos/plugin-google-genai with GOOGLE_IMAGE_MODEL set).
  3. Start the ElizaOS server (elizaos dev).
  4. In a Telegram chat with the bot, send an image by selecting it as a "Photo" (using the compressed/gallery option), not as a "File".
  5. Observe the server logs. The application will throw a TypeError and likely fail to respond to the message.

3. Expected behavior
The processImage function should not crash. It should successfully call runtime.useModel with the correct parameters, receive an image description, and create a valid attachment object that can be passed to the main message processing pipeline.

4. Logs
Here is the relevant stack trace from the crash:

❌ Error processing image: TypeError: paramsObj is not an Object. (evaluating '"prompt" in paramsObj')
      at useModel (.../node_modules/@elizaos/core/dist/node/index.node.js:48866:53)
      at processImage (.../node_modules/@elizaos/plugin-telegram/dist/index.js:207:59)
      at async processMessage (.../node_modules/@elizaos/plugin-telegram/dist/index.js:431:36)
      ...```

**5. Suggested Fix**
The call to `useModel` inside the `processImage` function in `plugin-telegram/src/messageManager.ts` needs to be updated to match the expected `ImageDescriptionParams` interface.

The current implementation is:
```typescript
const { title, description } = await this.runtime.useModel(
  ModelType.IMAGE_DESCRIPTION,
  imageUrl
);

This should be changed to pass an object, and it should also include the user's caption as the prompt for better contextual analysis:

const { title, description } = await this.runtime.useModel(
  ModelType.IMAGE_DESCRIPTION,
  { 
    imageUrl: imageUrl,
    prompt: message.caption || "Describe this image." 
  }
);

This change aligns the function call with the core @elizaos/core type definitions and resolves the TypeError.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions