{"record":{"id":"e887cb0a0d11be0c","repo":"larksuite/cli","slug":"s-d-must-be-a-non-blank-trimmed-scope","errorCode":null,"errorMessage":"%s[%d] must be a non-blank trimmed scope","messagePattern":"(.+?)\\[(.+?)\\] must be a non-blank trimmed scope","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compiler.go","lineNumber":176,"sourceCode":"\t\tseen := make(map[typedIdentity]struct{}, len(metadata.Authorization.IdentityOrder))\n\t\tfor _, identity := range metadata.Authorization.IdentityOrder {\n\t\t\tif _, ok := metadata.Authorization.Identities[identity]; !ok {\n\t\t\t\treturn fmt.Errorf(\"Metadata.Authorization.IdentityOrder contains undeclared identity %q\", identity)\n\t\t\t}\n\t\t\tif _, duplicate := seen[identity]; duplicate {\n\t\t\t\treturn fmt.Errorf(\"Metadata.Authorization.IdentityOrder contains duplicate identity %q\", identity)\n\t\t\t}\n\t\t\tseen[identity] = struct{}{}\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc validateScopeList(scopes []string, path string) error {\n\tseen := make(map[string]struct{}, len(scopes))\n\tfor i, scope := range scopes {\n\t\tif strings.TrimSpace(scope) == \"\" || scope != strings.TrimSpace(scope) {\n\t\t\treturn fmt.Errorf(\"%s[%d] must be a non-blank trimmed scope\", path, i)\n\t\t}\n\t\tif _, ok := seen[scope]; ok {\n\t\t\treturn fmt.Errorf(\"%s contains duplicate scope %q\", path, scope)\n\t\t}\n\t\tseen[scope] = struct{}{}\n\t}\n\treturn nil\n}\n\nfunc shortcutFromCompiled(compiled *compiledCommand) Shortcut {\n\tmetadata := compiled.metadata\n\tshortcut := Shortcut{\n\t\tService:     string(metadata.Service),\n\t\tCommand:     metadata.Command,\n\t\tDescription: metadata.Description,\n\t\tRisk:        string(metadata.Risk),\n\t\tHidden:      metadata.Hidden,\n\t\ttyped:       compiled,","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compiler.go#L158-L194","documentation":"validateScopeList enforces that every entry in a scopes slice (RequiredScopes or ConditionalScopes[i].Scopes) is a non-empty string with no surrounding whitespace. An empty or blank entry, or one with leading/trailing spaces, is rejected with its index in the path.","triggerScenarios":"RequiredScopes contains \"\" or \"  \"; a scope string like \" im:message \" with surrounding spaces; slices built dynamically where an empty string slips in (e.g. strings.Split producing an empty element).","commonSituations":"Copy-pasting scope lists from docs with trailing whitespace; splitting a comma-separated scope string without trimming; uninitialized placeholder entries left in a literal.","solutions":["Trim each scope string and remove blank entries before compiling","Replace the empty/whitespace entry at the reported index with a valid scope name","If deriving scopes from a joined string, use strings.Split then strings.TrimSpace and filter empties"],"exampleFix":"// before\nRequiredScopes: []string{\"im:message\", \" im:chat \"},\n// after\nRequiredScopes: []string{\"im:message\", \"im:chat\"},","handlingStrategy":"validation","validationCode":"for i, s := range scopes { if strings.TrimSpace(s) == \"\" || s != strings.TrimSpace(s) { return fmt.Errorf(\"scope[%d] blank or untrimmed\", i) } }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Trim and filter scope strings at construction time","When splitting a joined scope string, TrimSpace each element and skip empties","Never leave placeholder empty strings in scope literals"],"tags":["go","validation","shortcut-compiler","authorization-scopes"],"backgroundTag":"schema-validation-failed","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}