larksuite/cli · error
empty pattern
Error message
empty pattern
What it means
validateGlob rejects an empty glob pattern outright with 'empty pattern' before consulting doublestar. An empty pattern is meaningless, so the library treats it as a configuration error rather than silently accepting a no-op rule.
Source
Thrown at internal/cmdpolicy/validate.go:69
}
}
for _, g := range r.Deny {
if err := validateGlob(g); err != nil {
return fmt.Errorf("invalid deny glob %q: %w", g, err)
}
}
return nil
}
// validateGlob rejects malformed doublestar patterns. doublestar.Match
// returns an error for unbalanced brackets / bad escape sequences; that
// error path is the canonical signal for "this pattern is not valid".
//
// We probe with an empty string -- the goal is to exercise the parser,
// not to compute a match.
func validateGlob(g string) error {
if g == "" {
return fmt.Errorf("empty pattern")
}
if _, err := doublestar.Match(g, ""); err != nil {
return err
}
return nil
}
View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Remove the empty entry from the allow/deny list.
- If the value comes from a variable, ensure it is set and non-empty before rendering.
- If no patterns are needed, delete the whole allow or deny key.
Example fix
// before allow: - "docs/*" - "" // after allow: - "docs/*"
Defensive patterns
Strategy: validation
Validate before calling
for _, g := range append(append([]string{}, rule.Allow...), rule.Deny...) {
if strings.TrimSpace(g) == "" {
return fmt.Errorf("empty glob entry")
}
} Type guard
func hasEmptyPattern(list []string) bool {
for _, g := range list { if g == "" { return true } }
return false
} Prevention
- Filter empty strings out of allow/deny lists when generating config.
- Avoid emitting bare '-' list items in YAML templates.
- Make generators omit the allow/deny key entirely when the list is empty.
- Trim and check env-var-derived values before substituting into policy files.
When it happens
Trigger: ValidateRule sees an Allow or Deny entry that is the empty string "", typically from a YAML list with a bare '-' item, a generator emitting empty list items, or an unset variable substituted into the policy.
Common situations: Config generators emitting empty entries; YAML like 'allow:\n -' producing an empty-string item; template rendering where an unset variable left an empty pattern.
Related errors
- invalid allow glob %q: %w
- invalid deny glob %q: %w
- invalid identities entry %q: must be 'user' or 'bot'
- Invalid column: {column!r}
- Invalid column index: {index}
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/65b87a4cb195193f.
Report an issue: GitHub.