{"record":{"id":"6f4e8dddeb96f5cf","repo":"crowdsecurity/crowdsec","slug":"while-parsing-s-w-6f4e8d","errorCode":null,"errorMessage":"while parsing '%s': %w","messagePattern":"while parsing '(.+?)': %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/apiserver/apic.go","lineNumber":224,"sourceCode":"\t\tpullInterval:              pullIntervalDefault,\n\t\tpullIntervalFirst:         randomDuration(pullIntervalDefault, pullIntervalDelta),\n\t\tpushInterval:              pushIntervalDefault,\n\t\tpushIntervalFirst:         randomDuration(pushIntervalDefault, pushIntervalDelta),\n\t\tmetricsInterval:           metricsIntervalDefault,\n\t\tmetricsIntervalFirst:      randomDuration(metricsIntervalDefault, metricsIntervalDelta),\n\t\tusageMetricsInterval:      usageMetricsInterval,\n\t\tusageMetricsIntervalFirst: randomDuration(usageMetricsInterval, usageMetricsIntervalDelta),\n\t\tusageMetricsBatchBytes:    usageMetricsBatchBytes,\n\t\tisPulling:                 make(chan bool, 1),\n\t\twhitelists:                apicWhitelist,\n\t\tpullBlocklists:            *config.PullConfig.Blocklists,\n\t\tpullCommunity:             *config.PullConfig.Community,\n\t\tshareSignals:              *config.Sharing,\n\t}\n\n\tapiURL, err := url.Parse(config.Credentials.URL)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"while parsing '%s': %w\", config.Credentials.URL, err)\n\t}\n\n\tpapiURL, err := url.Parse(config.Credentials.PapiURL)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"while parsing '%s': %w\", config.Credentials.PapiURL, err)\n\t}\n\n\tret.apiClient = apiclient.NewClient(&apiclient.Config{\n\t\tMachineID:      config.Credentials.Login,\n\t\tPassword:       strfmt.Password(config.Credentials.Password),\n\t\tURL:            apiURL,\n\t\tPapiURL:        papiURL,\n\t\tVersionPrefix:  \"v3\",\n\t\tUpdateScenario: ret.FetchScenariosListFromDB,\n\t\tTokenSave: func(ctx context.Context, token string) error {\n\t\t\treturn dbClient.SaveAPICToken(ctx, token)\n\t\t},\n\t})","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/apiserver/apic.go#L206-L242","documentation":"NewAPIC parses config.Credentials.URL with net/url.Parse and wraps failures with this message. It means the central API URL string in the crowdsec configuration is not a parseable absolute URL, so the CAPI client cannot be constructed and startup aborts.","triggerScenarios":"url.Parse(config.Credentials.URL) errors at crowdsec startup — e.g. URL contains control characters, an invalid percent-encoding, or a malformed scheme that url.Parse rejects (note: url.Parse accepts many odd strings, so this usually means genuinely broken characters).","commonSituations":"Copy-pasted credentials URL with trailing spaces/newlines or smart quotes; YAML folding mangled the URL with special characters (e.g. '#', ':' breaking quoting); hand-edited config.yaml with an unquoted URL containing '://' fragments; env interpolation produced an empty or garbage value.","solutions":["Open the crowdsec config and check the api.server/capi credentials URL for stray characters, whitespace, or unquoted values","Quote the URL in YAML (url: \"https://api.crowdsec.net/\") to avoid parser mangling","Test the string with a quick url.Parse snippet or echo it to spot invisible characters","Re-download/re-generate credentials (cscli capi register or reinstall defaults) if hand-editing broke them"],"exampleFix":"// before (config.yaml)\napi_url: http://api.crowdsec.net/\n// after (quoted, valid)\napi_url: \"https://api.crowdsec.net/\"","handlingStrategy":"validation","validationCode":"func validURL(s string) bool {\n\tu, err := url.Parse(s)\n\treturn err == nil && u.Scheme != \"\" && u.Host != \"\"\n}\nif !validURL(cfg.Credentials.URL) {\n\treturn errors.New(\"credentials.URL is not a valid absolute URL\")\n}","typeGuard":null,"tryCatchPattern":"apiURL, err := url.Parse(config.Credentials.URL)\nif err != nil {\n\treturn nil, fmt.Errorf(\"while parsing '%s': %w\", config.Credentials.URL, err)\n}","preventionTips":["Quote URLs in YAML config to avoid character mangling","Trim whitespace/control characters from config values before use","Never hand-edit credentials files; use cscli registration commands"],"tags":["config","url","crowdsec","startup"],"backgroundTag":"invalid-url","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"}