crowdsecurity/crowdsec · error

unknown data type '%s' for : '%s'

Error message

unknown data type '%s' for : '%s'

What it means

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.

Source

Thrown at pkg/exprhelpers/helpers.go:339

	var err error

	ok := false

	switch ftype {
	case "regex", "regexp":
		if fflag.Re2RegexpInfileSupport.IsEnabled() {
			_, ok = dataFileRe2[filename]
		} else {
			_, ok = dataFileRegex[filename]
		}
	case "string":
		_, ok = dataFile[filename]
	case "map":
		_, ok = dataFileMap[filename]
	case "bots":
		_, ok = dataFileBots[filename]
	default:
		err = fmt.Errorf("unknown data type '%s' for : '%s'", ftype, filename)
	}

	return ok, err
}

// Expr helpers

// func Get(arr []string, index int) string {
func Get(params ...any) (any, error) {
	arr := params[0].([]string)
	index := params[1].(int)

	if index >= len(arr) {
		return "", nil
	}

	return arr[index], nil
}

View on GitHub (pinned to 909b515798)

Solutions

  1. Correct the ftype argument to "datafile", "map", or "bots".
  2. Check the caller's configuration or expression for the misspelled data type name.
  3. Compare against the current version's supported types — the set may have changed between crowdsec releases.
  4. If you need a new type, extend existsInFileMaps and the corresponding stores rather than passing an unknown value.

Example fix

// before
Init(file, "ip", nil)
// after
Init(file, "datafile", nil)
Defensive patterns

Strategy: type-guard

Validate before calling

allowed := map[string]bool{"datafile": true, "map": true, "bots": true}
if !allowed[ftype] {
	return fmt.Errorf("unsupported data type %q", ftype)
}

Type guard

func isValidDataType(t string) bool {
	return t == "datafile" || t == "map" || t == "bots"
}

Try / catch

ok, err := existsInFileMaps(filename, ftype)
if err != nil {
	log.Errorf("data type check failed: %v", err)
	return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06). Data as JSON: /api/errors/f961f114b1da67aa. Report an issue: GitHub.