{"record":{"id":"f36c696418afd6ec","repo":"crowdsecurity/crowdsec","slug":"failed-to-parse-api-server-credentials-configurati","errorCode":null,"errorMessage":"failed to parse api server credentials configuration file '%s': %w","messagePattern":"failed to parse api server credentials configuration file '(.+?)': %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/csconfig/api.go","lineNumber":116,"sourceCode":"\treturn nil\n}\n\n// Load loads the online credentials from the specified file, returning fs.ErrNotExist if the file does not exist.\nfunc (o *OnlineApiClientCfg) Load() error {\n\to.Credentials = new(ApiCredentialsCfg)\n\n\tfcontent, err := os.ReadFile(o.CredentialsFilePath)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdec := yaml.NewDecoder(bytes.NewReader(fcontent))\n\tdec.KnownFields(true)\n\n\terr = dec.Decode(o.Credentials)\n\tif err != nil {\n\t\tif !errors.Is(err, io.EOF) {\n\t\t\treturn fmt.Errorf(\"failed to parse api server credentials configuration file '%s': %w\", o.CredentialsFilePath, err)\n\t\t}\n\t}\n\n\tswitch {\n\tcase o.Credentials.Login == \"\" && o.Credentials.Password == \"\" && o.Credentials.URL == \"\":\n\t\t// An empty credentials file just means the engine was never registered against CAPI.\n\t\tlog.Debugf(\"no CAPI credentials found in '%s', engine is not registered\", o.CredentialsFilePath)\n\t\to.Credentials = nil\n\tcase o.Credentials.Login == \"\":\n\t\tlog.Warningf(\"can't load CAPI credentials from '%s' (missing login field)\", o.CredentialsFilePath)\n\t\to.Credentials = nil\n\tcase o.Credentials.Password == \"\":\n\t\tlog.Warningf(\"can't load CAPI credentials from '%s' (missing password field)\", o.CredentialsFilePath)\n\t\to.Credentials = nil\n\tcase o.Credentials.URL == \"\":\n\t\tlog.Warningf(\"can't load CAPI credentials from '%s' (missing url field)\", o.CredentialsFilePath)\n\t\to.Credentials = nil\n\t}","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/csconfig/api.go#L98-L134","documentation":"YAML decoding of the online API credentials file failed with a non-EOF error. Because the decoder runs with KnownFields(true), both malformed YAML and unknown/misspelled keys in the file land here. The file exists and was read fine; its content does not match the expected schema.","triggerScenarios":"Thrown at pkg/csconfig/api.go:116 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the wrapped YAML error for line/key details","Remove unknown keys — strict parsing rejects leftovers from manual edits or old versions","If registration state is broken, back up the file and re-run `cscli capi register` to regenerate it"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}