{"record":{"id":"bf6c73a7c2ac616a","repo":"crowdsecurity/crowdsec","slug":"could-not-create-request-w","errorCode":null,"errorMessage":"could not create request: %w","messagePattern":"could not create request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/apiclient/auth_jwt.go","lineNumber":75,"sourceCode":"\t\tPassword:  t.Password,\n\t\tScenarios: t.Scenarios,\n\t}\n\n\t/*\n\t\twe don't use the main client, so let's build the body\n\t*/\n\tvar buf io.ReadWriter = &bytes.Buffer{}\n\tenc := json.NewEncoder(buf)\n\tenc.SetEscapeHTML(false)\n\n\terr = enc.Encode(auth)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not encode jwt auth body: %w\", err)\n\t}\n\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, fmt.Sprintf(\"%s%s/watchers/login\", t.URL, t.VersionPrefix), buf)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not create request: %w\", err)\n\t}\n\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\n\ttransport := t.Transport\n\tif transport == nil {\n\t\ttransport = http.DefaultTransport\n\t}\n\n\tclient := &http.Client{\n\t\tTransport: &retryRoundTripper{\n\t\t\tnext:             transport,\n\t\t\tmaxAttempts:      5,\n\t\t\twithBackOff:      true,\n\t\t\tretryStatusCodes: []int{http.StatusTooManyRequests, http.StatusServiceUnavailable, http.StatusGatewayTimeout, http.StatusInternalServerError},\n\t\t},\n\t}\n","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/apiclient/auth_jwt.go#L57-L93","documentation":"Returned by refreshJwtToken when http.NewRequestWithContext rejects the login URL built from the transport's URL and version prefix for the POST to /watchers/login — typically a malformed or unparsable API URL configuration. Wraps the request-construction error.","triggerScenarios":"Thrown at pkg/apiclient/auth_jwt.go:75 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the api_url in the crowdsec config (must be a valid URL)","Check for control characters or malformed scheme in the configured URL"],"exampleFix":null,"handlingStrategy":"fallback","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-14T00:17:10.932Z"}