{"record":{"id":"e346c5ad9b1fa530","repo":"crowdsecurity/crowdsec","slug":"building-request-w","errorCode":null,"errorMessage":"building request: %w","messagePattern":"building request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/apiclient/alerts_service.go","lineNumber":86,"sourceCode":"}\n\n// to demo query arguments\nfunc (s *AlertsService) List(ctx context.Context, opts AlertsListOpts) (*models.GetAlertsResponse, *Response, error) {\n\tu := fmt.Sprintf(\"%s/alerts\", s.client.URLPrefix)\n\n\tparams, err := qs.Values(opts)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"building query: %w\", err)\n\t}\n\n\tURI := u\n\tif len(params) > 0 {\n\t\tURI = fmt.Sprintf(\"%s?%s\", URI, params.Encode())\n\t}\n\n\treq, err := s.client.PrepareRequest(ctx, http.MethodGet, URI, nil)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"building request: %w\", err)\n\t}\n\n\talerts := models.GetAlertsResponse{}\n\n\tresp, err := s.client.Do(ctx, req, &alerts)\n\tif err != nil {\n\t\treturn nil, resp, fmt.Errorf(\"performing request: %w\", err)\n\t}\n\n\treturn &alerts, resp, nil\n}\n\n// to demo query arguments\nfunc (s *AlertsService) Delete(ctx context.Context, opts AlertsDeleteOpts) (*models.DeleteAlertsResponse, *Response, error) {\n\tparams, err := qs.Values(opts)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/apiclient/alerts_service.go#L68-L104","documentation":"Returned by AlertsService.List when the underlying HTTP request to GET /alerts cannot be constructed from the built URI, e.g. an invalid URL produced from the client's URLPrefix plus query parameters. Wraps the http.NewRequest-style error from PrepareRequest.","triggerScenarios":"Thrown at pkg/apiclient/alerts_service.go:86 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the LAPI URL configured for the client","Check the request context is not cancelled/deadline-exceeded"],"exampleFix":null,"handlingStrategy":"retry","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"}