crowdsecurity/crowdsec · error

parsing api url ('%s'): %w

Error message

parsing api url ('%s'): %w

What it means

Returned by InitLAPIClient when the configured Local API URL string cannot be parsed by net/url — e.g. missing scheme or malformed host. The offending input is the api_url configuration value, named in the message.

Source

Thrown at pkg/apiclient/client.go:102

		return subscriptionType
	}

	return ""
}

func (c *ApiClient) GetTokenRefreshChan() chan struct{} {
	jwtTransport := c.client.Transport.(*JWTTransport)
	return jwtTransport.TokenRefreshChan
}

type service struct {
	client *ApiClient
}

func InitLAPIClient(ctx context.Context, apiUrl string, papiUrl string, login string, password string, scenarios []string) error {
	apiURL, err := url.Parse(apiUrl)
	if err != nil {
		return fmt.Errorf("parsing api url ('%s'): %w", apiURL, err)
	}

	papiURL, err := url.Parse(papiUrl)
	if err != nil {
		return fmt.Errorf("parsing polling api url ('%s'): %w", papiURL, err)
	}

	pwd := strfmt.Password(password)

	client := NewClient(&Config{
		MachineID:     login,
		Password:      pwd,
		URL:           apiURL,
		PapiURL:       papiURL,
		VersionPrefix: "v1",
		UpdateScenario: func(_ context.Context) ([]string, error) {
			return scenarios, nil
		},

View on GitHub (pinned to 909b515798)

Solutions

  1. Fix api_url in config.yaml (e.g. http://127.0.0.1:8080/)
  2. Check for typos, missing scheme, or stray characters
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/apiclient/client.go:102 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/e47ee0d9c4ebdb58. Report an issue: GitHub.