wtfutil/wtf · error

newrelic http error (%s): %s

Error message

newrelic http error (%s): %s

What it means

Raised in the New Relic client's doRequest when the API responds with a non-200 status: the error embeds the HTTP status and the raw response body. Indicates the request reached New Relic but was rejected — usually an invalid X-Api-Key, bad endpoint, or API error.

Source

Thrown at modules/newrelic/client/http_helper.go:40

		return err
	}
	req.Header.Add("X-Api-Key", c.apiKey)
	req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
	return c.doRequest(req, out)
}

func (c *Client) doRequest(req *http.Request, out interface{}) error {
	resp, err := c.httpClient.Do(req)
	if err != nil {
		return err
	}
	defer func() { _ = resp.Body.Close() }()
	b, err := io.ReadAll(resp.Body)
	if err != nil {
		return err
	}
	if resp.StatusCode != 200 {
		return fmt.Errorf("newrelic http error (%s): %s", resp.Status, b)
	}
	if len(b) == 0 {
		b = []byte{'{', '}'}
	}
	err = json.Unmarshal(b, &out)
	if err != nil {
		return err
	}
	return nil
}

func encodeGetParams(params map[string]interface{}) string {
	s := url.Values{}
	for k, v := range params {
		switch val := v.(type) {
		case string:
			if val != "" {
				s.Add(k, val)

View on GitHub (pinned to bb838c1ccb)

Solutions

  1. Verify the New Relic API key configured for the widget is valid and has the needed scope
  2. Inspect the response body in the error for New Relic's error explanation
  3. Check the request URL/endpoint is correct for your account region (US vs EU)
  4. Handle 429 responses by backing off before retrying
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at modules/newrelic/client/http_helper.go:40 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of wtfutil/wtf@bb838c1ccb (2026-09-03). Data as JSON: /api/errors/b26b4ab6d6acfacc. Report an issue: GitHub.