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

add human friendly error messages #1154

Merged
merged 4 commits into from
Jul 25, 2023

Conversation

huseyinbabal
Copy link
Contributor

@huseyinbabal huseyinbabal commented Jul 18, 2023

Description

Changes proposed in this pull request:

  • Mapped error messages in bot packages
  • There is no need to add error mapping for mattermost since they already send readable error descriptions, we use them.

Here are the screenshots for testing results for different scenarios for Slack, Discord, and Mattermost

Slack

Screenshot 2023-07-21 at 13 36 39

Discord

Screenshot 2023-07-21 at 13 29 34

Testing

You can create an instance on Botkube Cloud Dev, and provide wrong creds, wrong channel, or not invited channel for each platform. You need to see human-friendly messages as shown above.

You need to run botkube deployment via go run ... on this branch after exporting

export CONFIG_PROVIDER_API_KEY=...
export CONFIG_PROVIDER_ENDPOINT=https://api-dev.botkube.io/graphql
export CONFIG_PROVIDER_IDENTIFIER=...

Related issue(s)

https://github.com/kubeshop/botkube-cloud/issues/520

@huseyinbabal huseyinbabal marked this pull request as ready for review July 19, 2023 11:45
@huseyinbabal huseyinbabal requested review from a team and PrasadG193 as code owners July 19, 2023 11:45
@pkosiec pkosiec self-assigned this Jul 19, 2023
@pkosiec pkosiec added the enhancement New feature or request label Jul 19, 2023
Copy link
Member

@pkosiec pkosiec left a comment

Choose a reason for hiding this comment

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

I see some problems with the approach:

  • we're losing context - we don't know which channel is invalid, or which channel the bot should join. These errors are user friendly, but unfortunately not helpful.
  • it will be hard to maintain, as some of the errors are wrapped even 2 times.
  • we still log less user friendly messages.

While the idea of error mapping of course totally makes sense, I'd suggest doing it in different way:

  • map the errors in corresponding Bots (like bot/socketslack.go, bot/discord.go)
    • avoid string comparison if possible: if discord/mattermost/slack packages export some errors, use them with errors.Is(...). Of course if that's not possible, then string comparison is our last resort.
    • add context like channel name and communication group name.
  • these errors will be still logged, wrapped and reported as they were in main. So user checking logs will be able to understand the issue, with all the details.

What do you think? Thanks!

@huseyinbabal
Copy link
Contributor Author

Hi @pkosiec here is what I did;

Slack

They don't have error model for our cases, so I couldn't use them, used error string instead

Discord

I have used their error model and re-mapped error with additional context

Mattermost

We don't need to do anything for mattermost since they already have error description, and they are human-readable.

Copy link
Member

@pkosiec pkosiec left a comment

Choose a reason for hiding this comment

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

👌 Looks good to me! Didn't test it but based on the screenshots I see that it works great.

@huseyinbabal huseyinbabal merged commit 09b63ff into kubeshop:main Jul 25, 2023
13 checks passed
@huseyinbabal huseyinbabal deleted the error-reporting branch July 25, 2023 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants