{"record":{"id":"fd643141eabb8da9","repo":"crowdsecurity/crowdsec","slug":"building-query-w","errorCode":null,"errorMessage":"building query: %w","messagePattern":"building query: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/apiclient/alerts_service.go","lineNumber":76,"sourceCode":"\t}\n\n\taddedIds := models.AddAlertsResponse{}\n\n\tresp, err := s.client.Do(ctx, req, &addedIds)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\n\treturn &addedIds, resp, nil\n}\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}","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/apiclient/alerts_service.go#L58-L94","documentation":"AlertsService.List converts AlertsListOpts into URL query parameters with go-querystring; an option field the encoder cannot handle (unsupported type/missing qs tag requirement) makes query construction fail before the request is sent.","triggerScenarios":"Thrown at pkg/apiclient/alerts_service.go:76 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use valid filter values in AlertsListOpts","Check option fields contain supported types/values"],"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"}