Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Slack client Media type implementation missing required properties in message attachments #1384

Closed
SumeetChougule opened this issue Dec 23, 2024 · 2 comments · Fixed by #1741
Labels
bug Something isn't working

Comments

@SumeetChougule
Copy link
Contributor

SumeetChougule commented Dec 23, 2024

Describe the Bug

TypeScript type error in Slack client when handling message attachments. The error occurs because the attachments property in the Content interface expects an array of Media type objects, but the code was only providing a subset of the required properties.

Error message:

Type '{ text: string; }[]' is not assignable to type 'Media[]'.
Type '{ text: string; }' is missing the following properties from type 'Media': id, url, title, source, description

To Reproduce

  1. Use the Slack client implementation.
  2. Try to create a message content with attachments.
  3. The code attempts to create an attachment with only the text property:
attachments: attachmentContent ? [{ text: attachmentContent }] : undefined

Expected Behavior

The code should properly implement the Media type interface by providing all required properties:

  • id (string)
  • url (string)
  • title (string)
  • source (string)
  • description (string)
  • text (string)

Solution

Update the attachment creation to include all required Media type properties:

attachments: attachmentContent
    ? [{
        id: stringToUuid(`${event.ts}-attachment`),
        url: '',  // Since this is text content, no URL is needed
        title: 'Text Attachment',
        source: 'slack',
        description: 'Text content from Slack message',
        text: attachmentContent
    }]
    : undefined,

Additional Context

This issue affects the Slack client's message handling functionality in the packages/client-slack/src/messages.ts file. The fix ensures type safety while maintaining the intended functionality of handling text attachments from Slack messages.

@SumeetChougule SumeetChougule added the bug Something isn't working label Dec 23, 2024
@tcm390 tcm390 self-assigned this Dec 26, 2024
@AIFlowML
Copy link
Collaborator

AIFlowML commented Jan 3, 2025

Hello here.
Yopu are right i should have added all the media types.
I wil try look into it asap.

@AIFlowML
Copy link
Collaborator

AIFlowML commented Jan 3, 2025

Just pushed #1741
Tnks @SumeetChougule

@tcm390 tcm390 removed their assignment Jan 4, 2025
shakkernerd added a commit that referenced this issue Jan 4, 2025
…chments

fix(client-slack): implement Media type properties in message attachments #1384
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
4 participants