{"record":{"id":"4d2e9e78513d4211","repo":"crowdsecurity/crowdsec","slug":"path-is-too-short-s-d","errorCode":null,"errorMessage":"path is too short: %s (%d)","messagePattern":"path is too short: (.+?) \\((.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cwhub/sync.go","lineNumber":40,"sourceCode":"type itemSpec struct {\n\tpath  string // full path to the file (or link)\n\tfname string // name of the item:\n\t// for local item, taken from the file content or defaults to the filename (including extension)\n\t// for non-local items, always {author}/{name}\n\tstage   string // stage for parsers and overflows\n\tftype   string // type, plural (collections, contexts etc.)\n\tfauthor string // author - empty for local items\n\tinhub   bool   // true if the spec comes from the hub dir\n\ttarget  string // the target of path if it's a link, otherwise == path\n\tlocal   bool   // is this a spec for a local item?\n}\n\nfunc newHubItemSpec(path string, subs []string) (*itemSpec, error) {\n\t// .../hub/parsers/s00-raw/crowdsecurity/skip-pretag.yaml\n\t// .../hub/scenarios/crowdsecurity/ssh_bf.yaml\n\t// .../hub/profiles/crowdsecurity/linux.yaml\n\tif len(subs) < 3 {\n\t\treturn nil, fmt.Errorf(\"path is too short: %s (%d)\", path, len(subs))\n\t}\n\n\tftype := subs[0]\n\tif !slices.Contains(ItemTypes, ftype) {\n\t\t// this doesn't really happen anymore, because we only scan the {hubtype} directories\n\t\treturn nil, fmt.Errorf(\"unknown configuration type '%s'\", ftype)\n\t}\n\n\tstage := \"\"\n\tfauthor := subs[1]\n\tfname := subs[2]\n\n\tif ftype == PARSERS || ftype == POSTOVERFLOWS {\n\t\tif len(subs) < 4 {\n\t\t\treturn nil, fmt.Errorf(\"path is too short: %s (%d)\", path, len(subs))\n\t\t}\n\n\t\tstage = subs[1]","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/cwhub/sync.go#L22-L58","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before: file at hub/scenarios/my_scenario.yaml (no author dir)\nmv /etc/crowdsec/hub/scenarios/my_scenario.yaml /etc/crowdsec/hub/scenarios/crowdsecurity/my_scenario.yaml\n// after: correct layout .../hub/<type>/<author>/<name>.yaml","handlingStrategy":"validation","validationCode":"import (\n\t\"path/filepath\"\n\t\"strings\"\n)\n\nfunc isValidHubPath(hubDir, file string) bool {\n\trel, err := filepath.Rel(hubDir, file)\n\tif err != nil {\n\t\treturn false\n\t}\n\tdepth := len(strings.Split(filepath.ToSlash(rel), \"/\"))\n\treturn depth >= 3 // <type>/<author>/<name>.yaml\n}","typeGuard":null,"tryCatchPattern":"spec, err := cwhub.NewItemSpec(...) // or run Hub.Load\nif err != nil {\n\tlog.Warnf(\"skipping unclassifiable hub file: %v\", err)\n\treturn nil // skip instead of failing the whole sync\n}","preventionTips":["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"],"tags":["hub","path","layout","crowdsec"],"backgroundTag":"path-too-short","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"}