crowdsecurity/crowdsec · error
%s: %w
Error message
%s: %w
What it means
Wraps failures from i.FetchContentTo during `cscli hub` download operations. FetchContentTo fetches the item's archive/content from the hub (local or remote) into finalPath; any error is prefixed with the item's fully-qualified name so the user knows which item failed.
Source
Thrown at pkg/hubops/download.go:176
}
return needReload, nil
}
func (c *DownloadCommand) Run(ctx context.Context, plan *ActionPlan) error {
i := c.Item
fmt.Fprintf(os.Stdout, "downloading %s\n", colorizeItemName(i.FQName()))
// ensure that target file is within target dir
finalPath, err := i.PathForDownload()
if err != nil {
return err
}
downloaded, _, err := i.FetchContentTo(ctx, c.contentProvider, finalPath)
if err != nil {
return fmt.Errorf("%s: %w", i.FQName(), err)
}
if downloaded {
plan.ReloadNeeded = true
}
i.State.Tainted = false
i.State.UpToDate = true
// read content to get the list of data files
reader, err := os.Open(finalPath)
if err != nil {
return fmt.Errorf("while opening %s: %w", finalPath, err)
}
defer reader.Close()
needReload, err := downloadDataSet(ctx, plan.hub.GetDataDir(), c.Force, reader)View on GitHub (pinned to 909b515798)
Solutions
- Check connectivity to the hub and run `cscli hub update` to refresh the index.
- Read the wrapped error for the specific cause (DNS, 404, write permission).
- For persistent 404s, remove and reinstall the item: `cscli <type> remove <item> --force` then `cscli <type> install <item>`.
- Verify the install/data directories are writable by the crowdsec user.
Defensive patterns
Strategy: try-catch
Validate before calling
if err := checkHubConnectivity(); err != nil {
return fmt.Errorf("hub unreachable, aborting: %w", err)
} Try / catch
downloaded, _, err := item.FetchContentTo(ctx, cp, path)
if err != nil {
return fmt.Errorf("hub fetch failed for %s: %w", item.FQName(), err)
} Prevention
- Run `cscli hub update` regularly so the local index matches upstream.
- Ensure outbound connectivity to the CrowdSec hub/CAPI from the host.
- Keep the install/data directories writable and with sufficient disk space.
- Reinstall items cleanly if a previous download was interrupted.
When it happens
Trigger: Running `cscli hub update`/`install`/`upgrade` (Run of the download operation) when the hub content fetch fails: CAPI unreachable, item not present in the hub index, corrupted local tarmac, or write failure to the destination path.
Common situations: No outbound connectivity to the CrowdSec hub/API; stale local hub index after upstream items were removed; disk full or read-only install directory; interrupted prior download left bad state.
Understand the failure class
Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.
Related errors
- while getting data: %w
- %s is already downloaded at %s
- while downloading data for %s: %w
- while downloading data for %s: %w
- while enabling %s: %w
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/7a663ffd84deb3c4.
Report an issue: GitHub.