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

  1. Supply a non-empty comma-separated list, e.g. "user-a,user-b"
  2. Check the source config/env for the blank value and set it explicitly
  3. 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

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


AI-assisted analysis of ginuerzh/gost@a33fdbf4c9 (2026-09-02). Data as JSON: /api/errors/d760e8b4b7bf6aeb. Report an issue: GitHub.