{"record":{"id":"2129245abf3f55d0","repo":"crowdsecurity/crowdsec","slug":"unable-to-load-appsec-config-s-s","errorCode":null,"errorMessage":"unable to load appsec-config %s : %s","messagePattern":"unable to load appsec-config (.+?) : (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/appsec/appsec.go","lineNumber":883,"sourceCode":"\t\treturn PhaseHooks{}, wrap(err)\n\t}\n\n\tif out.OnMatch, err = buildHookList(ctx, onMatch, hookOnMatch, patcher); err != nil {\n\t\treturn PhaseHooks{}, wrap(err)\n\t}\n\n\treturn out, nil\n}\n\nfunc (wc *AppsecConfig) Load(configName string, hub *cwhub.Hub) error {\n\titem := hub.GetItem(cwhub.APPSEC_CONFIGS, configName)\n\n\tif item != nil && item.State.IsInstalled() {\n\t\twc.Logger.Infof(\"loading %s\", item.State.LocalPath)\n\n\t\terr := wc.LoadByPath(item.State.LocalPath)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to load appsec-config %s : %s\", item.State.LocalPath, err)\n\t\t}\n\n\t\treturn nil\n\t}\n\n\treturn fmt.Errorf(\"no appsec-config found for %s\", configName)\n}\n\nfunc (wc *AppsecConfig) Build(ctx context.Context, hub *cwhub.Hub) (*AppsecRuntimeConfig, error) {\n\tret := &AppsecRuntimeConfig{Logger: wc.Logger.WithField(\"component\", \"appsec_runtime_config\")}\n\n\tret.RequestValidator = apivalidation.NewRequestValidator(wc.Logger.WithField(\"component\", \"api_validator\"))\n\n\tif wc.BouncerBlockedHTTPCode == 0 {\n\t\twc.BouncerBlockedHTTPCode = http.StatusForbidden\n\t}\n\n\tif wc.BouncerPassedHTTPCode == 0 {","sourceCodeStart":865,"sourceCodeEnd":901,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/appsec/appsec.go#L865-L901","documentation":"AppsecConfig.Load resolves an appsec config by name from the hub and loads its installed local file via LoadByPath. If the installed file fails to load for any reason (unreadable, invalid YAML, bad hooks — everything from LoadByPath), the error is wrapped with the config's local path. Note it uses %s (not %w) for the inner error, so errors.Is/As chains are broken here.","triggerScenarios":"Load(configName, hub) where the hub item is installed but its LocalPath file fails LoadByPath: missing file, YAML parse error, unknown key, invalid on_success, expr compile failure.","commonSituations":"Hub-installed appsec config edited in place and broken; partial hub install; loading a config name whose files were removed; a custom appsec-config committed to the hub folder with a syntax error.","solutions":["Read the inner error after the path for the specific cause (parse error line, missing hook, expr failure)","Run cscli appsec-configs update/install to restore an unmodified copy of the hub config","Fix the custom YAML at the printed LocalPath (valid keys, valid on_success, compilable filters)","Avoid editing hub-managed files in place; put overrides in a separate custom config"],"exampleFix":"// before (edited hub file)\nfilters: [\"broken expr here(\"]\n// after\ncscli appsec-configs install crowdsecurity/virtual-patching -f  # restore pristine file","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify hub install state before loading","Avoid in-place edits of hub configs"],"tags":["appsec","config","hub"],"backgroundTag":"config-file-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"}