crowdsecurity/crowdsec · error

invalid item name %s

Error message

invalid item name %s

What it means

Hub.GetItemFQ expects a fully-qualified item name in the form "type:name" (e.g. "collections:crowdsecurity/linux"), split on ':'. If the string doesn't contain exactly one colon producing two parts, the name is rejected before any lookup.

Source

Thrown at pkg/cwhub/hub.go:193

}

// GetItemMap returns the map of items for a given type.
func (h *Hub) GetItemMap(itemType string) map[string]*Item {
	return h.items[itemType]
}

// 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 {

View on GitHub (pinned to 909b515798)

Solutions

  1. Pass the full "type:name" string, e.g. GetItemFQ("collections:crowdsecurity/linux")
  2. Strip or validate user input before calling GetItemFQ
  3. Use GetItemMap(type) directly when you already know the type

Example fix

// before
item, err := hub.GetItemFQ("crowdsecurity/linux")
// after
item, err := hub.GetItemFQ("collections:crowdsecurity/linux")
Defensive patterns

Strategy: validation

Validate before calling

func isFQName(s string) bool {
    parts := strings.Split(s, ":")
    return len(parts) == 2 && parts[0] != "" && parts[1] != ""
}

Prevention

When it happens

Trigger: Calling GetItemFQ with a bare name like "linux", a name with multiple colons like "collections:auth:linux", or an empty string; also hit indirectly via whyTainted when callers pass unqualified names.

Common situations: Passing `cscli`-style short names to hub APIs; copy-pasting an FQ name with an extra colon; programmatic lookups that forgot to prepend the item type.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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