crowdsecurity/crowdsec · error

invalid item type %s

Error message

invalid item type %s

What it means

GetItemFQ splits the FQ name and looks up h.GetItemMap(type). If the type segment is not one of the known hub item types (parsers, postoverflows, scenarios, collections, etc.), the map is nil and this error is returned.

Source

Thrown at pkg/cwhub/hub.go:198

}

// GetItem returns an item from hub based on its type and full name (author/name).
func (h *Hub) GetItem(itemType string, itemName string) *Item {
	return h.GetItemMap(itemType)[itemName]
}

// GetItemFQ returns an item from hub based on its type and name (type:author/name).
func (h *Hub) GetItemFQ(itemFQName string) (*Item, error) {
	// type and name are separated by a colon
	parts := strings.Split(itemFQName, ":")

	if len(parts) != 2 {
		return nil, fmt.Errorf("invalid item name %s", itemFQName)
	}

	m := h.GetItemMap(parts[0])
	if m == nil {
		return nil, fmt.Errorf("invalid item type %s", parts[0])
	}

	i := m[parts[1]]
	if i == nil {
		return nil, fmt.Errorf("item %s:%s not found", parts[0], parts[1])
	}

	return i, nil
}

// GetItemsByType returns a slice of all the items of a given type, installed or not, optionally sorted by case-insensitive name.
// A non-existent type will silently return an empty slice.
func (h *Hub) GetItemsByType(itemType string, sorted bool) []*Item {
	items := h.items[itemType]

	ret := make([]*Item, len(items))

	if sorted {

View on GitHub (pinned to 909b515798)

Solutions

  1. Use an exact valid type: parsers, postoverflows, scenarios, collections, contexts, appsec-configs, etc.
  2. Validate the type with h.GetItemMap(type) != nil before calling
  3. List valid types via cscli hubtypes / the cwhub exported constants

Example fix

// before
item, err := hub.GetItemFQ("scenario:crowdsecurity/ssh-bf")
// after
item, err := hub.GetItemFQ("scenarios:crowdsecurity/ssh-bf")
Defensive patterns

Strategy: validation

Validate before calling

if hub.GetItemMap(itemType) == nil {
    return fmt.Errorf("unknown hub type %q", itemType)
}

Prevention

When it happens

Trigger: GetItemFQ("parser:foo") or any misspelled/unknown type word as the prefix before the colon; called directly or via whyTainted with user-supplied type strings.

Common situations: Typos like "scenario" vs "scenarios"; older/renamed item types passed from stored config; user input from CLI flags not validated against the known types.

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/427720f5316c8099. Report an issue: GitHub.