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

Display specific error message if fail to retrieve permissions caused by rate limit #8658

Merged
merged 4 commits into from
Nov 18, 2024

Conversation

PopDaph
Copy link
Contributor

@PopDaph PopDaph commented Nov 15, 2024

Description

This is a change on the Slack connector. Currently, when there's an error while trying to retrieve permission (which we use on the permission modal + on the modal to set an assistant as default to answer in a Slack channel), we always display the wording "Failed to retrieve permissions likely due to a revoked authorization.", which is not necessarily true, the error can be something else such as hitting a rate limit from Slack: The goal of this PR is to display a proper message on these screens when the error we hit is a rate limit from Slack.

To do so, in connectors, in case of a rate limit:

  • SlackManager.retrievePermissions() can return a ProviderWorkflowError.
  • The connector API route to retrieve permission can return a "connector_rate_limit_error" which is an existing error code in connector.

In front:

  • When calling connector API, if we get a "connector_rate_limit_error" we answer a "rate_limit_error" which is a frontAPI error type.
  • Update the hook useConnectorPermissions to also return the error (not just a boolean to know if there's an error).
  • Update UseResourcesHook to have this optional new param with the error.
  • In ContentNodeTreeChildren, if there's an error and it's a rate limit error, we display a proper message.

This is not fixing the why we get a rate limit, but this error message is much clearer and less scary for users (their token is not revoked, we are still syncing their data).

Screenshot 2024-11-15 at 09 27 41

Risk

Can be rolled back but since it's both front & connector it's annoying.

Deploy Plan

  • Deploy front.
  • Deploy connectors.

@PopDaph PopDaph force-pushed the failed-permissions-rate-limit branch from deee4b3 to cf38d98 Compare November 15, 2024 08:27
connectors/src/connectors/slack/index.ts Outdated Show resolved Hide resolved
Comment on lines 112 to 119
if (connectorsRes.error.type === "connector_rate_limit_error") {
return new Err(
new Error(
connectorsRes.error.message ??
"An error occurred while fetching the resources' content nodes."
)
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not doing this for any error ? connectorsRes.error.message will usually provide more useful information ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I asked myself the question and decided to not do it because they are usually not user friendly messages and not meant to be user facing. I simplified the code pointed here though!

@PopDaph PopDaph merged commit ba7b9d8 into main Nov 18, 2024
3 checks passed
@PopDaph PopDaph deleted the failed-permissions-rate-limit branch November 18, 2024 09:55
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 this pull request may close these issues.

2 participants