grafana/k6 · error
secret value at path %q is not a string (got %s)
Error message
secret value at path %q is not a string (got %s)
What it means
When the gjson path does resolve, the module only accepts string values; if result.Type is not gjson.String (number, bool, null, object...) this error reports the actual type. The secret source requires the selected JSON field to be a string.
Source
Thrown at internal/secretsource/url/url.go:260
}
if len(data) > maxSecretSize {
return "", fmt.Errorf("secret response exceeds maximum size of %d bytes", maxSecretSize)
}
if responsePath == "" {
// If no path specified, assume response body is the secret
return string(data), nil
}
result := gjson.GetBytes(data, responsePath)
if !result.Exists() {
return "", fmt.Errorf("path %q not found in response", responsePath)
}
if result.Type != gjson.String {
return "", fmt.Errorf("secret value at path %q is not a string (got %s)", responsePath, result.Type)
}
return result.String(), nil
}
// retry retries to execute a provided function until it succeeds or the maximum
// number of attempts is hit. It waits with exponential backoff between attempts.
// The backoff calculation is: wait = (base ^ attempt) + random jitter up to 1 second.
// The do function returns an error and a boolean indicating if the error is retryable.
func retry(
ctx context.Context,
attempts int,
baseBackoff time.Duration,
logger logrus.FieldLogger,
do func() (error, bool),
) error {
r := rand.New(rand.NewSource(time.Now().UnixNano())) //nolint:gosec
View on GitHub (pinned to 01ffac6f24)
Solutions
- Point responsePath at a string field in the response
- Change the service to return the secret as a JSON string
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/secretsource/url/url.go:260 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/46cc9cda626f1ba4.
Report an issue: GitHub.