crowdsecurity/crowdsec · error

building request: %w

Error message

building request: %w

What it means

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.

Source

Thrown at pkg/apiclient/alerts_service.go:86

}

// 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)
	}

	return &alerts, resp, nil
}

// to demo query arguments
func (s *AlertsService) Delete(ctx context.Context, opts AlertsDeleteOpts) (*models.DeleteAlertsResponse, *Response, error) {
	params, err := qs.Values(opts)
	if err != nil {
		return nil, nil, err
	}

View on GitHub (pinned to 909b515798)

Solutions

  1. Verify the LAPI URL configured for the client
  2. Check the request context is not cancelled/deadline-exceeded
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at pkg/apiclient/alerts_service.go:86 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/e346c5ad9b1fa530. Report an issue: GitHub.