larksuite/cli · error
%s[%d] must be a non-blank trimmed scope
Error message
%s[%d] must be a non-blank trimmed scope
What it means
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.
Source
Thrown at shortcuts/common/typed_compiler.go:176
seen := make(map[typedIdentity]struct{}, len(metadata.Authorization.IdentityOrder))
for _, identity := range metadata.Authorization.IdentityOrder {
if _, ok := metadata.Authorization.Identities[identity]; !ok {
return fmt.Errorf("Metadata.Authorization.IdentityOrder contains undeclared identity %q", identity)
}
if _, duplicate := seen[identity]; duplicate {
return fmt.Errorf("Metadata.Authorization.IdentityOrder contains duplicate identity %q", identity)
}
seen[identity] = struct{}{}
}
}
return nil
}
func validateScopeList(scopes []string, path string) error {
seen := make(map[string]struct{}, len(scopes))
for i, scope := range scopes {
if strings.TrimSpace(scope) == "" || scope != strings.TrimSpace(scope) {
return fmt.Errorf("%s[%d] must be a non-blank trimmed scope", path, i)
}
if _, ok := seen[scope]; ok {
return fmt.Errorf("%s contains duplicate scope %q", path, scope)
}
seen[scope] = struct{}{}
}
return nil
}
func shortcutFromCompiled(compiled *compiledCommand) Shortcut {
metadata := compiled.metadata
shortcut := Shortcut{
Service: string(metadata.Service),
Command: metadata.Command,
Description: metadata.Description,
Risk: string(metadata.Risk),
Hidden: metadata.Hidden,
typed: compiled,View on GitHub (pinned to 7fd6ef3c07)
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
Example fix
// before
RequiredScopes: []string{"im:message", " im:chat "},
// after
RequiredScopes: []string{"im:message", "im:chat"}, Defensive patterns
Strategy: validation
Validate before calling
for i, s := range scopes { if strings.TrimSpace(s) == "" || s != strings.TrimSpace(s) { return fmt.Errorf("scope[%d] blank or untrimmed", i) } } Prevention
- 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
When it happens
Trigger: 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).
Common situations: Copy-pasting scope lists from docs with trailing whitespace; splitting a comma-separated scope string without trimming; uninitialized placeholder entries left in a literal.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- %s.When must be trimmed
- %s.Requirement %q is invalid
- %s contains duplicate scope %q
- Metadata.Authorization.IdentityOrder must contain each decla
- Metadata.Authorization.IdentityOrder contains undeclared ide
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/e887cb0a0d11be0c.
Report an issue: GitHub.