{"record":{"id":"f961f114b1da67aa","repo":"crowdsecurity/crowdsec","slug":"unknown-data-type-s-for-s","errorCode":null,"errorMessage":"unknown data type '%s' for : '%s'","messagePattern":"unknown data type '(.+?)' for : '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/exprhelpers/helpers.go","lineNumber":339,"sourceCode":"\tvar err error\n\n\tok := false\n\n\tswitch ftype {\n\tcase \"regex\", \"regexp\":\n\t\tif fflag.Re2RegexpInfileSupport.IsEnabled() {\n\t\t\t_, ok = dataFileRe2[filename]\n\t\t} else {\n\t\t\t_, ok = dataFileRegex[filename]\n\t\t}\n\tcase \"string\":\n\t\t_, ok = dataFile[filename]\n\tcase \"map\":\n\t\t_, ok = dataFileMap[filename]\n\tcase \"bots\":\n\t\t_, ok = dataFileBots[filename]\n\tdefault:\n\t\terr = fmt.Errorf(\"unknown data type '%s' for : '%s'\", ftype, filename)\n\t}\n\n\treturn ok, err\n}\n\n// Expr helpers\n\n// func Get(arr []string, index int) string {\nfunc Get(params ...any) (any, error) {\n\tarr := params[0].([]string)\n\tindex := params[1].(int)\n\n\tif index >= len(arr) {\n\t\treturn \"\", nil\n\t}\n\n\treturn arr[index], nil\n}","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/exprhelpers/helpers.go#L321-L357","documentation":"existsInFileMaps checks whether a filename is loaded in the in-memory store matching the given ftype (datafile/map/bots). This error is thrown when the ftype argument is not one of the recognized data types, meaning the lookup can't be dispatched; ok is returned false with the error set.","triggerScenarios":"Calling FileInit (which calls existsInFileMaps) with an ftype string other than \"datafile\", \"map\", or \"bots\" — e.g. \"file\", \"ip\", or a type name from an expression helper that was renamed.","commonSituations":"Custom parsers or expressions referencing a data file with an unsupported type name; typos in the FileInit type argument; API changes between crowdsec versions renaming a data type.","solutions":["Correct the ftype argument to \"datafile\", \"map\", or \"bots\".","Check the caller's configuration or expression for the misspelled data type name.","Compare against the current version's supported types — the set may have changed between crowdsec releases.","If you need a new type, extend existsInFileMaps and the corresponding stores rather than passing an unknown value."],"exampleFix":"// before\nInit(file, \"ip\", nil)\n// after\nInit(file, \"datafile\", nil)","handlingStrategy":"type-guard","validationCode":"allowed := map[string]bool{\"datafile\": true, \"map\": true, \"bots\": true}\nif !allowed[ftype] {\n\treturn fmt.Errorf(\"unsupported data type %q\", ftype)\n}","typeGuard":"func isValidDataType(t string) bool {\n\treturn t == \"datafile\" || t == \"map\" || t == \"bots\"\n}","tryCatchPattern":"ok, err := existsInFileMaps(filename, ftype)\nif err != nil {\n\tlog.Errorf(\"data type check failed: %v\", err)\n\treturn err\n}","preventionTips":["Reference data types by constants, not inline strings","Re-check supported type names after crowdsec upgrades","Search existing calls to FileInit for the canonical type strings before adding new ones"],"tags":["data-files","enum","crowdsec"],"backgroundTag":"invalid-enum-value","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}