crowdsecurity/crowdsec · error
path is too short: %s (%d)
Error message
path is too short: %s (%d)
What it means
newHubItemSpec splits a file path under the hub directory into path segments ('subs') and expects at least <type>/<author>/<name> for most item types (e.g. .../hub/scenarios/crowdsecurity/ssh_bf.yaml). If fewer than 3 segments are found below the hub root, the path does not follow the hub layout and cannot be turned into an itemSpec, so this error is returned. It is a structural validation of hub file locations during hub sync.
Source
Thrown at pkg/cwhub/sync.go:40
type itemSpec struct {
path string // full path to the file (or link)
fname string // name of the item:
// for local item, taken from the file content or defaults to the filename (including extension)
// for non-local items, always {author}/{name}
stage string // stage for parsers and overflows
ftype string // type, plural (collections, contexts etc.)
fauthor string // author - empty for local items
inhub bool // true if the spec comes from the hub dir
target string // the target of path if it's a link, otherwise == path
local bool // is this a spec for a local item?
}
func newHubItemSpec(path string, subs []string) (*itemSpec, error) {
// .../hub/parsers/s00-raw/crowdsecurity/skip-pretag.yaml
// .../hub/scenarios/crowdsecurity/ssh_bf.yaml
// .../hub/profiles/crowdsecurity/linux.yaml
if len(subs) < 3 {
return nil, fmt.Errorf("path is too short: %s (%d)", path, len(subs))
}
ftype := subs[0]
if !slices.Contains(ItemTypes, ftype) {
// this doesn't really happen anymore, because we only scan the {hubtype} directories
return nil, fmt.Errorf("unknown configuration type '%s'", ftype)
}
stage := ""
fauthor := subs[1]
fname := subs[2]
if ftype == PARSERS || ftype == POSTOVERFLOWS {
if len(subs) < 4 {
return nil, fmt.Errorf("path is too short: %s (%d)", path, len(subs))
}
stage = subs[1]View on GitHub (pinned to 909b515798)
Solutions
- Move the file into the proper hub layout: <hubdir>/<type>/<author>/<name>.yaml
- Remove or relocate stray files that don't belong in the hub directory (use the config/install directory for local items instead)
- Verify HUBDIR in your config points to the hub working directory (e.g. /etc/crowdsec/hub), not a parent or child of it
- Re-download the hub with 'cscli hub update' if the tree looks corrupted
Example fix
// before: file at hub/scenarios/my_scenario.yaml (no author dir) mv /etc/crowdsec/hub/scenarios/my_scenario.yaml /etc/crowdsec/hub/scenarios/crowdsecurity/my_scenario.yaml // after: correct layout .../hub/<type>/<author>/<name>.yaml
Defensive patterns
Strategy: validation
Validate before calling
import (
"path/filepath"
"strings"
)
func isValidHubPath(hubDir, file string) bool {
rel, err := filepath.Rel(hubDir, file)
if err != nil {
return false
}
depth := len(strings.Split(filepath.ToSlash(rel), "/"))
return depth >= 3 // <type>/<author>/<name>.yaml
} Try / catch
spec, err := cwhub.NewItemSpec(...) // or run Hub.Load
if err != nil {
log.Warnf("skipping unclassifiable hub file: %v", err)
return nil // skip instead of failing the whole sync
} Prevention
- Never place or edit files by hand inside the hub directory; it is managed by cscli
- Keep local customizations in the config directory, not the hub directory
- After manual hub operations, run 'cscli hub update' to restore a consistent tree
When it happens
Trigger: Walking h.local.HubDir finds a file whose path relative to the hub directory has fewer than 3 segments, e.g. a yaml dropped directly under hub/scenarios/ or hub/<type>/file.yaml with no author directory.
Common situations: Manually copying a .yaml into a hub type directory without the author subdirectory; a misconfigured HUBDIR pointing at the wrong tree depth; half-deleted hub checkouts; symlinks resolving outside the expected layout.
Related errors
- file '%s' is not from hub '%s' nor from the configuration di
- no parser found. Please install the appropriate parser and r
- unknown configuration type '%s'
- %s: %w
- failed to sync %s: %w
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/4d2e9e78513d4211.
Report an issue: GitHub.