{"record":{"id":"d6801b2abb03376f","repo":"m1k1o/neko","slug":"invalid-stream-selector-type-s","errorCode":null,"errorMessage":"invalid stream selector type: %s","messagePattern":"invalid stream selector type: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/pkg/types/capture.go","lineNumber":88,"sourceCode":"\tcase StreamSelectorTypeHigher:\n\t\treturn \"higher\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"%d\", int(s))\n\t}\n}\n\nfunc (s *StreamSelectorType) UnmarshalText(text []byte) error {\n\tswitch strings.ToLower(string(text)) {\n\tcase \"exact\", \"\":\n\t\t*s = StreamSelectorTypeExact\n\tcase \"nearest\":\n\t\t*s = StreamSelectorTypeNearest\n\tcase \"lower\":\n\t\t*s = StreamSelectorTypeLower\n\tcase \"higher\":\n\t\t*s = StreamSelectorTypeHigher\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid stream selector type: %s\", string(text))\n\t}\n\treturn nil\n}\n\nfunc (s StreamSelectorType) MarshalText() ([]byte, error) {\n\treturn []byte(s.String()), nil\n}\n\ntype StreamSelector struct {\n\t// type of stream selector\n\tType StreamSelectorType `json:\"type\"`\n\t// select stream by its ID\n\tID string `json:\"id\"`\n\t// select stream by its bitrate\n\tBitrate uint64 `json:\"bitrate\"`\n}\n\ntype StreamSelectorManager interface {","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/m1k1o/neko/blob/b0f01cedea68893e85a3fd852c0521238c285695/server/pkg/types/capture.go#L70-L106","documentation":"StreamSelectorType.UnmarshalText parses a textual stream-selection mode and only accepts the known cases (e.g., \"nearest\", \"lower\", \"higher\"). Any other string fails with this error. It surfaces from JSON/TOML/YAML text unmarshalling of configuration that uses StreamSelectorType fields.","triggerScenarios":"Unmarshalling a config file or API payload (encoding/json TextUnmarshaler, yaml/toml wrappers) into a StreamSelectorType field where the text is not one of the accepted constants — e.g., \"auto\", \"lowest\", \"Highest\", or an empty string.","commonSituations":"Typo in config (\"higer\", \"low\"); case mismatch since parsing is case-sensitive (\"Higher\" fails); upgrading from an older config that used a removed alias; hand-writing YAML/JSON values without checking StreamSelectorType.String() output.","solutions":["Set the value to one of the accepted literals exactly as defined in StreamSelectorType.String(): \"nearest\", \"lower\", or \"higher\".","Fix case: parsing is case-sensitive, so use lowercase (\"higher\", not \"Higher\").","Check for typos/whitespace in the config value and consult capture.go for the current list of valid StreamSelectorType constants."],"exampleFix":"// before (config.json)\n\"streamSelector\": \"Highest\"\n// after\n\"streamSelector\": \"higher\"","handlingStrategy":"validation","validationCode":"valid := map[string]bool{\"nearest\": true, \"lower\": true, \"higher\": true}\nif !valid[strings.ToLower(strings.TrimSpace(cfg.StreamSelector))] {\n    return fmt.Errorf(\"streamSelector must be nearest|lower|higher\")\n}","typeGuard":"func isValidStreamSelector(s string) bool {\n    var t types.StreamSelectorType\n    return t.UnmarshalText([]byte(s)) == nil\n}","tryCatchPattern":"var sel types.StreamSelectorType\nif err := json.Unmarshal(raw, &sel); err != nil {\n    if strings.Contains(err.Error(), \"invalid stream selector type\") {\n        sel = types.StreamSelectorTypeNearest // safe default\n    } else {\n        return err\n    }\n}","preventionTips":["Keep config values exactly matching StreamSelectorType.String() output (lowercase: nearest/lower/higher).","Add schema validation (JSON schema or config loader validation) for enum fields.","Use the enum constants in code instead of string literals when setting values programmatically.","Verify config changes against StreamSelectorType.MarshalText output before deploying."],"tags":["validation","unmarshal","config"],"backgroundTag":"invalid-enum-value","analyzedSha":"b0f01cedea68893e85a3fd852c0521238c285695","analyzedAt":"2026-09-01T10:35:56.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}