crowdsecurity/crowdsec · error
building query: %w
Error message
building query: %w
What it means
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.
Source
Thrown at pkg/apiclient/alerts_service.go:76
}
addedIds := models.AddAlertsResponse{}
resp, err := s.client.Do(ctx, req, &addedIds)
if err != nil {
return nil, resp, err
}
return &addedIds, resp, nil
}
// to demo query arguments
func (s *AlertsService) List(ctx context.Context, opts AlertsListOpts) (*models.GetAlertsResponse, *Response, error) {
u := fmt.Sprintf("%s/alerts", s.client.URLPrefix)
params, err := qs.Values(opts)
if err != nil {
return nil, nil, fmt.Errorf("building query: %w", err)
}
URI := u
if len(params) > 0 {
URI = fmt.Sprintf("%s?%s", URI, params.Encode())
}
req, err := s.client.PrepareRequest(ctx, http.MethodGet, URI, nil)
if err != nil {
return nil, nil, fmt.Errorf("building request: %w", err)
}
alerts := models.GetAlertsResponse{}
resp, err := s.client.Do(ctx, req, &alerts)
if err != nil {
return nil, resp, fmt.Errorf("performing request: %w", err)
}View on GitHub (pinned to 909b515798)
Solutions
- Use valid filter values in AlertsListOpts
- Check option fields contain supported types/values
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pkg/apiclient/alerts_service.go:76 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/fd643141eabb8da9.
Report an issue: GitHub.