{"record":{"id":"ecf651cb7a6adf3e","repo":"bytebase/bytebase","slug":"missing-the-following-scopes-s","errorCode":null,"errorMessage":"missing the following scopes: %s","messagePattern":"missing the following scopes: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/plugin/webhook/slack/app.go","lineNumber":102,"sourceCode":"\t\treturn errors.Wrapf(err, \"failed to unmarshal\")\n\t}\n\tif !res.OK {\n\t\treturn errors.Errorf(\"failed to test auth, error: %v\", res.Error)\n\t}\n\n\tscopes := resp.Header.Get(\"x-oauth-scopes\")\n\thasScope := map[string]bool{}\n\tfor _, s := range strings.Split(scopes, \",\") {\n\t\thasScope[s] = true\n\t}\n\tvar missScope []string\n\tfor _, s := range []string{\"users:read\", \"users:read.email\", \"channels:manage\", \"groups:write\", \"im:write\", \"chat:write\", \"mpim:write\"} {\n\t\tif !hasScope[s] {\n\t\t\tmissScope = append(missScope, s)\n\t\t}\n\t}\n\tif len(missScope) > 0 {\n\t\treturn errors.Errorf(\"missing the following scopes: %s\", strings.Join(missScope, \",\"))\n\t}\n\n\treturn nil\n}\n\nvar userIDCache = func() *lru.Cache[string, string] {\n\tcache, err := lru.New[string, string](5000)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn cache\n}()\n\n// https://api.slack.com/methods/users.lookupByEmail\n// id=\"\" indicates that the user is not found.\nfunc (p *provider) lookupByEmail(ctx context.Context, email string) (id string, err error) {\n\tif id, ok := userIDCache.Get(email); ok {\n\t\treturn id, nil","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/bytebase/bytebase/blob/1870550677fe08f0d2a78c07acd27541464eb945/backend/plugin/webhook/slack/app.go#L84-L120","documentation":"authTest validates that the configured Slack bot token has every OAuth scope the Bytebase webhook integration needs (users:read, users:read.email, channels:manage, groups:write, im:write, chat:write, mpim:write). It collects the scopes present on the token via Slack's auth.test response and, if any required scope is absent, joins the missing list into this error. The message names exactly which scopes must be added to the Slack app.","triggerScenarios":"The bot token installed on the Slack workspace is missing one or more of the seven required scopes when authTest runs (during webhook provider configuration/testing).","commonSituations":"Slack app manifest omits scopes like channels:manage or im:write; scopes were changed in the Slack app settings but the app was never reinstalled into the workspace; using a legacy or user token instead of a bot token.","solutions":["Read the scope list in the error message and add each missing scope in Slack app settings under OAuth & Permissions.","Reinstall the app into the workspace so the new scopes are granted to the bot token.","Update the bot token (xoxb-...) in the Bytebase webhook configuration and re-run the test.","Ensure the token is a bot token, not a legacy or user token."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"requiredScopes := []string{\"users:read\", \"users:read.email\", \"channels:manage\", \"groups:write\", \"im:write\", \"chat:write\", \"mpim:write\"}\n// before configuring the webhook, verify the token grants all of them\n// via https://slack.com/api/auth.test response scopes (or the app manifest)\n","typeGuard":null,"tryCatchPattern":"if err := provider.Test(ctx, config); err != nil {\n\tif strings.Contains(err.Error(), \"missing the following scopes\") {\n\t\t// surface the scope list to the admin and prompt for app reinstall\n\t\treturn fmt.Errorf(\"slack app needs reinstall with scopes: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Define the Slack app manifest with all seven required scopes up front.","Reinstall the app into the workspace whenever scopes change.","Always use a bot token (xoxb-), never a legacy or user token.","Run the connection test after any Slack app configuration change."],"tags":["slack","oauth","scopes","configuration"],"backgroundTag":"insufficient-permissions","analyzedSha":"1870550677fe08f0d2a78c07acd27541464eb945","analyzedAt":"2026-09-06T21:16:13.665Z","contentChangedAt":"2026-09-06T21:16:13.665Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}