{"record":{"id":"1926807367c04f7d","repo":"crowdsecurity/crowdsec","slug":"no-embedded-content-for-s","errorCode":null,"errorMessage":"no embedded content for %s","messagePattern":"no embedded content for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cwhub/fetch.go","lineNumber":22,"sourceCode":"\t\"bytes\"\n\t\"context\"\n\t\"crypto\"\n\t\"encoding/base64\"\n\t\"encoding/hex\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"path/filepath\"\n\n\t\"github.com/crowdsecurity/go-cs-lib/downloader\"\n)\n\n// writeEmbeddedContentTo writes the embedded content to the specified path and checks the hash.\n// If the content is base64 encoded, it will be decoded before writing. Call this method only\n// if item.Content if not empty.\nfunc (i *Item) writeEmbeddedContentTo(destPath, wantHash string) error {\n\tif i.Content == \"\" {\n\t\treturn fmt.Errorf(\"no embedded content for %s\", i.Name)\n\t}\n\n\tcontent, err := base64.StdEncoding.DecodeString(i.Content)\n\tif err != nil {\n\t\tcontent = []byte(i.Content)\n\t}\n\n\tdir := filepath.Dir(destPath)\n\treader := bytes.NewReader(content)\n\thash := crypto.SHA256.New()\n\n\ttee := io.TeeReader(reader, hash)\n\tif err := os.MkdirAll(dir, 0o755); err != nil {\n\t\treturn fmt.Errorf(\"while creating %s: %w\", dir, err)\n\t}\n\n\tf, err := os.OpenFile(destPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o600)\n\tif err != nil {","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/cwhub/fetch.go#L4-L40","documentation":"writeEmbeddedContentTo is only safe to call when Item.Content is populated (non-empty) from the downloaded index. It returns this error when the item has no embedded content, meaning the caller proceeded down the embedded-content path incorrectly.","triggerScenarios":"Calling FetchContentTo on an item whose index entry has an empty Content field but a non-empty latestHash — i.e. the index says the item has a hash but no inline base64 content.","commonSituations":"Corrupted or partially written hub index file, an index produced by an older hub version without embedded content, or manually edited index entries.","solutions":["Run `sudo cscli hub update` to refresh the index file","If it persists, delete the hub index file (`/var/lib/crowdsec/data/hub/.index.json`) and re-run `cscli hub update`","Check crowdsec/hub version compatibility and upgrade if mismatched"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if item.Content == \"\" {\n    // fall back to network download instead of embedded write\n    return fetchViaNetwork(ctx, item, destPath)\n}","typeGuard":"func hasEmbeddedContent(i *cwhub.Item) bool { return i.Content != \"\" }","tryCatchPattern":"if err := item.FetchContentTo(ctx, provider, dest); err != nil {\n    if strings.Contains(err.Error(), \"no embedded content\") {\n        logger.Warnf(\"%s has no embedded content; forcing index refresh\", item.FQName())\n        return refreshHubIndex(ctx)\n    }\n    return err\n}","preventionTips":["Only call writeEmbeddedContentTo after checking Item.Content is non-empty","Keep the hub index freshly downloaded with regular `cscli hub update`","Never hand-edit the .index.json file"],"tags":["hub","index","embedded-content"],"backgroundTag":"missing-config-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"}