grafana/k6 · error

failed to extract secret: %w

Error message

failed to extract secret: %w

What it means

After a 200 response, extracting the secret from the body failed — reading the body or resolving the configured responsePath. The extraction step wraps its own error; see the cause for whether it was a read or path problem.

Source

Thrown at internal/secretsource/url/url.go:206

			// Network errors are retryable
			return fmt.Errorf("failed to get secret: %w", err), true
		}
		defer func() { _ = response.Body.Close() }()

		if response.StatusCode != http.StatusOK {
			statusErr := fmt.Errorf("status code %d: %w", response.StatusCode, errFailedToGetSecret)

			// Retry on server errors (5xx) and rate limiting (429)
			// Don't retry on client errors (4xx except 429)
			retryable := response.StatusCode >= 500 || response.StatusCode == http.StatusTooManyRequests
			return statusErr, retryable
		}

		// Extract secret value from response
		extractedSecret, err := extractSecretFromResponse(response.Body, us.config.ResponsePath.String)
		if err != nil {
			// Extraction errors are not retryable (indicates config issue)
			return fmt.Errorf("failed to extract secret: %w", err), false
		}

		secret = extractedSecret
		return nil, false
	})
	if err != nil {
		return "", err
	}

	return secret, nil
}

type limiter interface {
	Wait(ctx context.Context) error
}

func newLimiter(requestsPerMinuteLimit, requestsBurst int) *rate.Limiter {
	// The calculation below looks wrong because it seems like it's giving

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Check the wrapped error: 'path not found' means the responsePath doesn't match the JSON; read errors mean connection issues
  2. Verify responsePath (a gjson path) against the actual service response
  3. Omit responsePath if the whole body is the secret
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at internal/secretsource/url/url.go:206 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/5eb1578e67e496d1. Report an issue: GitHub.