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

Unknown block type when decoding chat.postMessage response #14

Open
Leonid99 opened this issue May 28, 2022 · 4 comments
Open

Unknown block type when decoding chat.postMessage response #14

Leonid99 opened this issue May 28, 2022 · 4 comments
Assignees

Comments

@Leonid99
Copy link

Leonid99 commented May 28, 2022

When doing (event API in socket mode):

        let response = post_message(&socket_mode.api_client, &request, &socket_mode.bot_token)
            .await
            .expect("post message api error.");

I am getting the following error:

thread 'main' panicked at 'post message api error.: SerdeJsonError(Error("unknown variant `rich_text`, expected one of `actions`, `context`, `divider`, `file`, `header`, `image`, `input`, `section`", line: 1, column: 682))', src/main.rs:60:14

The list of variants seems to suggest that there is an unsupported block type (the documentation doesn't list "rich_text" as a possible Block type).

This is happening when I am sending a message to the bot I'm working on from the normal Slack client.

@Gompei Gompei self-assigned this May 28, 2022
@Leonid99
Copy link
Author

Leonid99 commented May 28, 2022

{
    "ok": true,
    "channel": "DKVSHS1HC",
    "ts": "1653756786.810519",
    "message": {
        "bot_id": "BKTND7QN4",
        "type": "message",
        "text": "Hello World!!",
        "user": "UKGA4ARMY",
        "ts": "1653756786.810519",
        "app_id": "AJ9649K6F",
        "team": "T3GV5VB0D",
        "bot_profile": {
            "id": "BKTND7QN4",
            "app_id": "AJ9649K6F",
            "name": "Rookie",
            "icons": {
                "image_36": "https://avatars.slack-edge.com/2019-06-23/673287830948_0affbbb86beca00aa028_36.png",
                "image_48": "https://avatars.slack-edge.com/2019-06-23/673287830948_0affbbb86beca00aa028_48.png",
                "image_72": "https://avatars.slack-edge.com/2019-06-23/673287830948_0affbbb86beca00aa028_72.png"
            },
            "deleted": false,
            "updated": 1561328910,
            "team_id": "T3GV5VB0D"
        },
        "blocks": [
            {
                "type": "rich_text",
                "block_id": "Zjof6",
                "elements": [
                    {
                        "type": "rich_text_section",
                        "elements": [
                            {
                                "type": "text",
                                "text": "Hello World!!"
                            }
                        ]
                    }
                ]
            }
        ]
    }
}

@Leonid99
Copy link
Author

I am a complete rust newb, but what I don't understand is why it is an error. From the documentation, it sounds like serde should ignore json values it is not aware of, unless #[serde(deny_unknown_fields)] is provided.

@Gompei Gompei added this to the v0.0.2-alpha release milestone Aug 8, 2022
@dselans
Copy link

dselans commented Jun 21, 2023

@Leonid99 did you figure out a way around this?

@dselans
Copy link

dselans commented Jun 21, 2023

I went ahead and forked + added a minor patch for the rich_text Block variant as it was bugging me 😄

https://github.com/dselans/slack-rust

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants