ginuerzh/gost · error
cannot be empty
Error message
cannot be empty
What it means
ParseStringSet rejects an empty string because a StringSet with no entries is meaningless as a comma-separated list and usually signals a missing configuration value. The parse would otherwise silently produce an empty set.
Source
Thrown at permissions.go:113
func (ps *PortSet) Contains(value int) bool {
for _, portRange := range *ps {
if portRange.Contains(value) {
return true
}
}
return false
}
// StringSet is a set of string.
type StringSet []string
// ParseStringSet parses the s to a StringSet.
// The s shoud be a comma separated string.
func ParseStringSet(s string) (*StringSet, error) {
ss := &StringSet{}
if s == "" {
return nil, errors.New("cannot be empty")
}
*ss = strings.Split(s, ",")
return ss, nil
}
// Contains checks whether the string subj within this StringSet.
func (ss *StringSet) Contains(subj string) bool {
for _, s := range *ss {
if glob.Glob(s, subj) {
return true
}
}
return false
}
View on GitHub (pinned to a33fdbf4c9)
Solutions
- Supply a non-empty comma-separated list, e.g. "user-a,user-b"
- Check the source config/env for the blank value and set it explicitly
- If an empty list is valid in your application, guard the call: skip parsing when the input is empty
Example fix
// before
ss, err := permissions.ParseStringSet(str) // str == ""
// after
var ss *permissions.StringSet
if str != "" {
ss, err = permissions.ParseStringSet(str)
} Defensive patterns
Strategy: validation
Validate before calling
if strings.TrimSpace(s) == "" {
return errors.New("string set must be non-empty")
}
ss, err := permissions.ParseStringSet(s) Try / catch
if err != nil {
return fmt.Errorf("invalid permissions %q: %w", s, err)
} Prevention
- Treat empty allowlists as config errors and fail fast at load time
- Trim and check inputs interpolated from env/config
- Document required fields in config templates
When it happens
Trigger: Calling ParseStringSet("") directly, or ParsePermissions with the corresponding string field left blank.
Common situations: Empty allowlist/denylist entry in a config file, unset environment variable interpolated into the permissions string, or a UI field left blank.
Related errors
- ErrInvalidNode
- must specify at least one port
- action list must look like connect,bind given: %s
- hosts list must look like google.pl,*.google.com given: %s
- permission must have format [actions]:[hosts]:[ports] given:
AI-assisted analysis of ginuerzh/gost@a33fdbf4c9 (2026-09-02).
Data as JSON: /api/errors/d760e8b4b7bf6aeb.
Report an issue: GitHub.