{"record":{"id":"79f0d673f84214b0","repo":"crowdsecurity/crowdsec","slug":"item-s-s-not-found","errorCode":null,"errorMessage":"item %s:%s not found","messagePattern":"item (.+?):(.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cwhub/hub.go","lineNumber":203,"sourceCode":"}\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 {\n\t\tfor idx, name := range maptools.SortedKeysNoCase(items) {\n\t\t\tret[idx] = items[name]\n\t\t}\n\n\t\treturn ret","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/cwhub/hub.go#L185-L221","documentation":"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.","triggerScenarios":"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.","commonSituations":"Requesting a community item that doesn't exist; item was renamed upstream; stale local .index.json missing newly published items; typo in author/name.","solutions":["Run `cscli hub update` to refresh the index, then retry","Verify exact name with `cscli hub list` or the online hub catalog","Check the author prefix (e.g. crowdsecurity/ vs other authors)","Guard the lookup: treat the error as user-input feedback rather than a crash"],"exampleFix":"// before\nitem, _ := hub.GetItemFQ(\"collections:linux\") // panics later on nil item\n// after\nitem, err := hub.GetItemFQ(\"collections:crowdsecurity/linux\")\nif err != nil { return fmt.Errorf(\"unknown collection: %w\", err) }","handlingStrategy":"try-catch","validationCode":"m := hub.GetItemMap(itemType)\nif m != nil && m[itemName] == nil {\n    return fmt.Errorf(\"%s:%s not in hub; run 'cscli hub update'\", itemType, itemName)\n}","typeGuard":null,"tryCatchPattern":"item, err := hub.GetItemFQ(fq)\nvar notFound *string\nif err != nil {\n    if strings.Contains(err.Error(), \"not found\") {\n        return fmt.Errorf(\"unknown item %s (did you run 'cscli hub update'?)\", fq)\n    }\n    return err\n}","preventionTips":["Run cscli hub update before scripted installs","Verify item names against `cscli hub list` output","Handle not-found as user-input feedback, not a crash"],"tags":["hub","not-found","api"],"backgroundTag":"entity-not-found","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}