{"record":{"id":"427720f5316c8099","repo":"crowdsecurity/crowdsec","slug":"invalid-item-type-s","errorCode":null,"errorMessage":"invalid item type %s","messagePattern":"invalid item type (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cwhub/hub.go","lineNumber":198,"sourceCode":"}\n\n// GetItem returns an item from hub based on its type and full name (author/name).\nfunc (h *Hub) GetItem(itemType string, itemName string) *Item {\n\treturn h.GetItemMap(itemType)[itemName]\n}\n\n// GetItemFQ returns an item from hub based on its type and name (type:author/name).\nfunc (h *Hub) GetItemFQ(itemFQName string) (*Item, error) {\n\t// type and name are separated by a colon\n\tparts := strings.Split(itemFQName, \":\")\n\n\tif len(parts) != 2 {\n\t\treturn nil, fmt.Errorf(\"invalid item name %s\", itemFQName)\n\t}\n\n\tm := h.GetItemMap(parts[0])\n\tif m == nil {\n\t\treturn nil, fmt.Errorf(\"invalid item type %s\", parts[0])\n\t}\n\n\ti := m[parts[1]]\n\tif i == nil {\n\t\treturn nil, fmt.Errorf(\"item %s:%s not found\", parts[0], parts[1])\n\t}\n\n\treturn i, nil\n}\n\n// GetItemsByType returns a slice of all the items of a given type, installed or not, optionally sorted by case-insensitive name.\n// A non-existent type will silently return an empty slice.\nfunc (h *Hub) GetItemsByType(itemType string, sorted bool) []*Item {\n\titems := h.items[itemType]\n\n\tret := make([]*Item, len(items))\n\n\tif sorted {","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/cwhub/hub.go#L180-L216","documentation":"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.","triggerScenarios":"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.","commonSituations":"Typos like \"scenario\" vs \"scenarios\"; older/renamed item types passed from stored config; user input from CLI flags not validated against the known types.","solutions":["Use an exact valid type: parsers, postoverflows, scenarios, collections, contexts, appsec-configs, etc.","Validate the type with h.GetItemMap(type) != nil before calling","List valid types via cscli hubtypes / the cwhub exported constants"],"exampleFix":"// before\nitem, err := hub.GetItemFQ(\"scenario:crowdsecurity/ssh-bf\")\n// after\nitem, err := hub.GetItemFQ(\"scenarios:crowdsecurity/ssh-bf\")","handlingStrategy":"validation","validationCode":"if hub.GetItemMap(itemType) == nil {\n    return fmt.Errorf(\"unknown hub type %q\", itemType)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a set of valid hub types from cwhub constants and validate input against it","Centralize type parsing in one helper","Test lookups with table-driven cases covering all valid types"],"tags":["hub","api","type-error"],"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-14T00:17:10.932Z"}