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 variant rich_text #170

Open
Mattsi-Jansky opened this issue Jun 21, 2023 · 4 comments · May be fixed by #171
Open

unknown variant rich_text #170

Mattsi-Jansky opened this issue Jun 21, 2023 · 4 comments · May be fixed by #171

Comments

@Mattsi-Jansky
Copy link

I'm hitting some issues when parsing valid blocks sent back from the Slack API because they include type of rich_text which doesn't appear to be supported. And I'm struggling to find it anywhere in the Slack blocks documentation, so it might be undocumented?

Specifically, the error:

---- should_send_acknowledgement_of_event_messages stdout ----
thread 'should_send_acknowledgement_of_event_messages' panicked at 'called `Result::unwrap()` on an `Err` value: Error("unknown variant `rich_text`, expected one of `section`, `divider`, `image`, `actions`, `context`, `input`, `header`, `file`", line: 0, column: 0)', client/tests/web_sockets.rs:97:27

And the Slack message, which is a response from the api/chat.postMessage action, some identifying details omitted:

{
  "ok": true,
  "channel": "<ommitted>",
  "ts": "1686086970.626639",
  "message": {
    "bot_id": "<ommitted>",
    "type": "message",
    "text": "foobar",
    "user": "<ommitted>",
    "ts": "1686086970.626639",
    "app_id": "<ommitted>",
    "blocks": [
      {
        "type": "rich_text",
        "block_id": "<ommitted>",
        "elements": [
          {
            "type": "rich_text_section",
            "elements": [
              {
                "type": "text",
                "text": "foobar"
              }
            ]
          }
        ]
      }
    ],
    "team": "<ommitted>",
    "bot_profile": {
      "id": "<ommitted>",
      "app_id": "<ommitted>",
      "name": "<ommitted>",
      "icons": {
        "image_36": "<ommitted>",
        "image_48": "<ommitted>",
        "image_72": "<ommitted>"
      },
      "deleted": false,
      "updated": 1686039611,
      "team_id": "<ommitted>"
    }
  },
  "warning": "missing_charset",
  "response_metadata": {
    "warnings": [
      "missing_charset"
    ]
  }
}
@cakekindel
Copy link
Owner

Hi Mattsi! Just noticed this, I'll work on adding support for this tomorrow! 😃

@Mattsi-Jansky
Copy link
Author

Good stuff 👍 For what it's worth I've since discovered other undocumented parts of the Blocks API, like the link element and the rich_text_section element. They are returned by the API and work in the Block Kit Builder but aren't in the documentation.

I've been hacking together my own minimal implementation here that includes these non-documented types, if it helps as a reference: https://github.com/Mattsi-Jansky/termibot/tree/rewrite-in-rust/client/src/models/blocks

@cakekindel cakekindel linked a pull request Aug 29, 2023 that will close this issue
@cakekindel
Copy link
Owner

Sorry I dropped this! Added a minimal change to unblock this issue. May be worth considering adding a fallthrough variant as well to be more forward-compatible with Blocks changes going forward

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

Successfully merging a pull request may close this issue.

2 participants