{"record":{"id":"d760e8b4b7bf6aeb","repo":"ginuerzh/gost","slug":"cannot-be-empty","errorCode":null,"errorMessage":"cannot be empty","messagePattern":"cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"permissions.go","lineNumber":113,"sourceCode":"func (ps *PortSet) Contains(value int) bool {\n\tfor _, portRange := range *ps {\n\t\tif portRange.Contains(value) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n// StringSet is a set of string.\ntype StringSet []string\n\n// ParseStringSet parses the s to a StringSet.\n// The s shoud be a comma separated string.\nfunc ParseStringSet(s string) (*StringSet, error) {\n\tss := &StringSet{}\n\tif s == \"\" {\n\t\treturn nil, errors.New(\"cannot be empty\")\n\t}\n\n\t*ss = strings.Split(s, \",\")\n\n\treturn ss, nil\n}\n\n// Contains checks whether the string subj within this StringSet.\nfunc (ss *StringSet) Contains(subj string) bool {\n\tfor _, s := range *ss {\n\t\tif glob.Glob(s, subj) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/ginuerzh/gost/blob/a33fdbf4c98034f4bfeeaea9868909822b9c526d/permissions.go#L95-L131","documentation":"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.","triggerScenarios":"Calling ParseStringSet(\"\") directly, or ParsePermissions with the corresponding string field left blank.","commonSituations":"Empty allowlist/denylist entry in a config file, unset environment variable interpolated into the permissions string, or a UI field left blank.","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"],"exampleFix":"// before\nss, err := permissions.ParseStringSet(str) // str == \"\"\n// after\nvar ss *permissions.StringSet\nif str != \"\" {\n    ss, err = permissions.ParseStringSet(str)\n}","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(s) == \"\" {\n    return errors.New(\"string set must be non-empty\")\n}\nss, err := permissions.ParseStringSet(s)","typeGuard":null,"tryCatchPattern":"if err != nil {\n    return fmt.Errorf(\"invalid permissions %q: %w\", s, err)\n}","preventionTips":["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"],"tags":["config","validation","string-set"],"backgroundTag":"missing-or-empty-config-value","analyzedSha":"a33fdbf4c98034f4bfeeaea9868909822b9c526d","analyzedAt":"2026-09-02T22:15:54.506Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}