{"record":{"id":"204768ecfb5fe13b","repo":"crowdsecurity/crowdsec","slug":"file-s-is-not-from-hub-s-nor-from-the-config","errorCode":null,"errorMessage":"file '%s' is not from hub '%s' nor from the configuration directory '%s'","messagePattern":"file '(.+?)' is not from hub '(.+?)' nor from the configuration directory '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cwhub/sync.go","lineNumber":126,"sourceCode":"\tvar (\n\t\tspec *itemSpec\n\t\terr  error\n\t)\n\n\tif subs, ok := relativePathComponents(path, hubDir); ok {\n\t\tspec, err = newHubItemSpec(path, subs)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t} else if subs, ok := relativePathComponents(path, installDir); ok {\n\t\tspec, err = newInstallItemSpec(path, subs)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tif spec == nil {\n\t\treturn nil, fmt.Errorf(\"file '%s' is not from hub '%s' nor from the configuration directory '%s'\", path, hubDir, installDir)\n\t}\n\n\t// follow the link to see if it falls in the hub directory\n\t// if it's not a link, target == path\n\tspec.target, err = resolveSymlink(spec.path)\n\tif err != nil {\n\t\t// target does not exist, the user might have removed the file\n\t\t// or switched to a hub branch without it; or symlink loop\n\t\treturn nil, err\n\t}\n\n\ttargetInHub, err := isPathInside(spec.target, hubDir)\n\tif err != nil {\n\t\treturn nil, ErrSkipPath\n\t}\n\n\tspec.local = !targetInHub\n","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/cwhub/sync.go#L108-L144","documentation":"newItemSpec only builds an itemSpec when the file path is recognized as belonging either to the hub directory or to the local configuration (install) directory. When the path matches neither prefix (and the file cannot be attributed to any known root), there is no way to classify the item as downloaded, installed, or local, so this error is returned to the caller (itemVisit during sync).","triggerScenarios":"Hub.Load/localSync visits a file whose absolute path is neither under h.local.HubDir nor under h.local.InstallDir, e.g. through a symlink or an unusual syncDir root.","commonSituations":"A symlink in a scanned directory pointing to a file on another filesystem/parent directory outside both roots; a Hub configured with HubDir and InstallDir that don't cover the scanned tree; moving directories after install without re-running cscli.","solutions":["Check HubDir and InstallDir in your config cover the directory being scanned; fix the paths in config.yaml","Remove or fix dangling/misplaced symlinks so targets resolve under the hub or config directory","Reinstall the affected item with 'cscli hub item install' so the hub/config layout is rebuilt correctly"],"exampleFix":"// before: symlink in hub dir -> /home/user/foo.yaml (outside both roots)\nreadlink -f /etc/crowdsec/hub/scenarios/crowdsecurity/foo.yaml  # /home/user/foo.yaml\nrm /etc/crowdsec/hub/scenarios/crowdsecurity/foo.yaml\ncscli hub item install crowdsecurity/foo -t scenarios\n// after: item is a proper symlink (or copy) under hub/ or config/","handlingStrategy":"try-catch","validationCode":"func underOneOf(file string, roots ...string) bool {\n\tfor _, r := range roots {\n\t\trel, err := filepath.Rel(r, file)\n\t\tif err == nil && !strings.HasPrefix(rel, \"..\") {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n// before Load: verify hubDir and installDir are set and cover scanned trees\nif hubDir == \"\" || installDir == \"\" {\n\treturn fmt.Errorf(\"hub_dir and config dirs must be set\")\n}","typeGuard":null,"tryCatchPattern":"err := hub.Load(ctx)\nif err != nil {\n\tif strings.Contains(err.Error(), \"is not from hub\") {\n\t\t// unclassifiable file: resolve the symlink target and repair or remove it\n\t\tlog.Warnf(\"repairing misplaced item: %v\", err)\n\t} else {\n\t\treturn err\n\t}\n}","preventionTips":["Avoid symlinks in hub/config dirs pointing outside those trees","Keep hub_dir and install_dir inside the same crowdsec root (/etc/crowdsec)","Re-run cscli install commands after moving crowdsec directories"],"tags":["hub","path","symlink","classification","crowdsec"],"backgroundTag":"resource-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"}