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

Remove full event details from UnmarshallingErrorEvent #1067

Merged

Conversation

pkosiec
Copy link
Contributor

@pkosiec pkosiec commented May 19, 2022

Hi 👋

When an unknown Slack event is received (e.g. unsupported Huddle-related events like user_huddle_changed or sh_room_join), the library sends UnmarshallingErrorEvent containing full event details data, including some pieces of personal information about the user.

This is a part of this error message when calling err.Error() on such slack.UnmarshallingErrorEvent:

RTM Error: Received unmapped event "user_huddle_changed": {"type":"user_huddle_changed","user":{"id":"id","team_id":"team_id",name":"name","deleted":false,"color":"9f69e7","real_name":"name","tz":"timezone,"tz_label":"timezone_label","tz_offset":7200,"profile":{"title":"","phone":"","skype":"","real_name":"name","real_name_normalized":"name","display_name":"","display_name_normalized":"","fields":null,"status_text":"","status_emoji":"","status_emoji_display_info":[],"status_expiration":0,"avatar_hash":"g4c69e455b85","email":"email","huddle_state_expiration_ts":1652949419,"first_name":"name,"last_name":"","image_24":"...

It is a problem, because such error should be presented to a user in some way. As this is a string, it needs some string manipulation to remove the event details. I think it shouldn't work that way.

While there are different options to solve this, I went with the simplest option: do not concatenate the event details to the error message 🙂 It brings consistency across all errors that are returned as incoming events. Also, there is still debug logging around UnmarshallingErrorEvents, so basically the change doesn't impact anything.

Let me know what you think 🙂 Cheers!

mergify bot pushed a commit to kubeshop/botkube that referenced this pull request May 26, 2022
##### ISSUE TYPE
 - Bug fix Pull Request

##### SUMMARY

- Do not log full Slack event details in case of unmarshalling error

This is an issue of the upstream library. While I prepared a workaround, I also prepared a simple change in `slack-go/slack` repo: slack-go/slack#1067

**NOTE:** This pull request depends on #582. Please merge #582 first, and I will rebase this one.

Actual changes on this PR: 7813821

Fixes #579

##### TESTING

See the original issue for testing instruction: #579
You can use `pkosiec/botkube:slack-unmarshall-err` Docker image for testing the workaround.
Once you run my image and try to reproduce the issue, you'll see in the logs:

```
ERRO[2022-05-19T16:00:57Z] Slack unmarshalling error: RTM Error: Received unmapped event "user_huddle_changed"
ERRO[2022-05-19T16:00:57Z] Slack unmarshalling error: RTM Error: Received unmapped event "sh_room_join"
ERRO[2022-05-19T16:01:00Z] Slack unmarshalling error: RTM Error: Received unmapped event "sh_room_leave"
```
Copy link
Member

@kanata2 kanata2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
If an event is needed on error, we should provide one of the followings.

  • Debug mode ONLY
  • Return errors in a format that is easy to parse, such as JSON

I agree to remove it for now.

@kanata2 kanata2 merged commit 1dcd0d4 into slack-go:master Jun 6, 2022
@pkosiec pkosiec deleted the rm-event-details-from-unmarshalling-err branch June 6, 2022 07:07
mergify bot pushed a commit to kubeshop/botkube that referenced this pull request Jun 6, 2022
… details from logs #610

##### ISSUE TYPE
 - Feature Pull Request
 - Bug fix Pull Request
 - Docs Pull Request

##### SUMMARY

~⚠️ **NOTE:** For convienence, this PR depends on #603 and needs to be rebased when #603 is merged (it should happen very soon). Actual changes: a6d91f21f25f00d679572e62b45cd2396d571075~

As the upstream fix has been merged (slack-go/slack#1067), this PR updates `slack-go/slack` dependency and removes no longer needed workaround.

See the original issue: #579
See the PR that introduced the workaround: #583

##### TESTING

> **NOTE:** You can also use `pkosiec/botkube:rm-slack-workaround` Docker image for testing. The image was repushed **after** rebase.

1. Checkout this PR
2. Edit `comm_config.yaml` and enable Slack
3. Export needed envs:

```bash
export KUBECONFIG=/Users/$USER/.kube/config
export LOG_LEVEL=info
```

4. Run BotKube locally:

```bash
go run ./cmd/botkube/main.go
```

5. Start Slack huddle and say something, then leave
6. Observe logs still without event details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants