crowdsecurity/crowdsec · error

item %s:%s not found

Error message

item %s:%s not found

What it means

After validating type and name format, GetItemFQ looks up the item in the type's map. If no item with that name exists in the loaded hub index, this not-found error is returned. The hub index must have been loaded successfully for this lookup to work.

Source

Thrown at pkg/cwhub/hub.go:203

}

// 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 {
		for idx, name := range maptools.SortedKeysNoCase(items) {
			ret[idx] = items[name]
		}

		return ret

View on GitHub (pinned to 909b515798)

Solutions

  1. Run `cscli hub update` to refresh the index, then retry
  2. Verify exact name with `cscli hub list` or the online hub catalog
  3. Check the author prefix (e.g. crowdsecurity/ vs other authors)
  4. Guard the lookup: treat the error as user-input feedback rather than a crash

Example fix

// before
item, _ := hub.GetItemFQ("collections:linux") // panics later on nil item
// after
item, err := hub.GetItemFQ("collections:crowdsecurity/linux")
if err != nil { return fmt.Errorf("unknown collection: %w", err) }
Defensive patterns

Strategy: try-catch

Validate before calling

m := hub.GetItemMap(itemType)
if m != nil && m[itemName] == nil {
    return fmt.Errorf("%s:%s not in hub; run 'cscli hub update'", itemType, itemName)
}

Try / catch

item, err := hub.GetItemFQ(fq)
var notFound *string
if err != nil {
    if strings.Contains(err.Error(), "not found") {
        return fmt.Errorf("unknown item %s (did you run 'cscli hub update'?)", fq)
    }
    return err
}

Prevention

When it happens

Trigger: GetItemFQ with a well-formed "type:name" whose name is absent from the index — wrong author prefix, item not in the hub, or hub index not updated; invoked from whyTainted.

Common situations: Requesting a community item that doesn't exist; item was renamed upstream; stale local .index.json missing newly published items; typo in author/name.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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