grafana/k6 · error

sigV4 config `Region`, `AwsAccessKeyID`…

Error message

sigV4 config `Region`, `AwsAccessKeyID`, `AwsSecretAccessKey` must all be set

What it means

This is the second, stricter sigv4 check inside the signing round tripper itself (internal/output/prometheusrw/sigv4/tripper.go). Config.validate() requires Region, AwsAccessKeyID and AwsSecretAccessKey to be non-empty after whitespace trimming. It fires when a sigv4.Config reaches NewRoundTripper with a blank or whitespace-only field — including values that passed the earlier env-var presence check in remotewrite/config.go.

Solutions

  1. Give every one of the three sigv4 settings a non-empty, non-whitespace value
  2. Run `env | grep SIGV4` and re-export any variable that prints empty or padded
  3. Unset all three variables if sigv4 is not actually required
  4. If calling NewRoundTripper from Go, populate Region, AwsAccessKeyID and AwsSecretAccessKey and check the returned error before use

Example fix

# before
K6_PROMETHEUS_RW_SIGV4_REGION=""
K6_PROMETHEUS_RW_SIGV4_ACCESS_KEY=AKIA...
K6_PROMETHEUS_RW_SIGV4_SECRET_KEY=...

# after
K6_PROMETHEUS_RW_SIGV4_REGION=us-east-1
K6_PROMETHEUS_RW_SIGV4_ACCESS_KEY=AKIA...
K6_PROMETHEUS_RW_SIGV4_SECRET_KEY=...
Defensive patterns

Strategy: validation

Validate before calling

#!/usr/bin/env bash
set -eu
for v in K6_PROMETHEUS_RW_SIGV4_REGION K6_PROMETHEUS_RW_SIGV4_ACCESS_KEY K6_PROMETHEUS_RW_SIGV4_SECRET_KEY; do
  val="${!v:-}"
  if [ -n "$val" ] && [ -z "$(echo "$val" | tr -d '[:space:]')" ]; then
    echo "$v is set but whitespace-only" >&2; exit 1
  fi
done
# Go embedders:
// if strings.TrimSpace(cfg.Region) == "" || strings.TrimSpace(cfg.AwsAccessKeyID) == "" || strings.TrimSpace(cfg.AwsSecretAccessKey) == "" { return fmt.Errorf("sigv4 config incomplete") }
// if _, err := sigv4.NewRoundTripper(cfg, nil); err != nil { return err }

Prevention

When it happens

Trigger: All three K6_PROMETHEUS_RW_SIGV4_* variables are exported but one is empty or contains only spaces (e.g. `export K6_PROMETHEUS_RW_SIGV4_REGION=" "` or `=""`), so each null.String is Valid and the partial-config check passes, but the trimmed length is zero. Also hits Go code that calls sigv4.NewRoundTripper directly with a hand-built *Config missing a field, or passes a nil config (separate 'config should not be nil' error).

Common situations: CI secrets masked to empty strings when the vault lookup fails silently; `.env` files with `KEY=` lines; shell scripts that set variables conditionally and leave one blank; embedding k6 as a library and constructing sigv4.Config without all three fields.

Related errors


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

Appendix: source

Thrown at internal/output/prometheusrw/sigv4/tripper.go:31

	next   http.RoundTripper
}

// Config holds aws access configurations
type Config struct {
	Region             string
	AwsAccessKeyID     string
	AwsSecretAccessKey string
}

func (c *Config) validate() error {
	if c == nil {
		return errors.New("config should not be nil")
	}
	hasRegion := len(strings.TrimSpace(c.Region)) != 0
	hasAccessID := len(strings.TrimSpace(c.AwsAccessKeyID)) != 0
	hasSecretAccessKey := len(strings.TrimSpace(c.AwsSecretAccessKey)) != 0
	if !hasRegion || !hasAccessID || !hasSecretAccessKey {
		return errors.New("sigV4 config `Region`, `AwsAccessKeyID`, `AwsSecretAccessKey` must all be set")
	}
	return nil
}

// NewRoundTripper creates a new sigv4 round tripper
func NewRoundTripper(config *Config, next http.RoundTripper) (*Tripper, error) {
	if err := config.validate(); err != nil {
		return nil, err
	}

	if next == nil {
		next = http.DefaultTransport
	}

	tripper := &Tripper{
		config: config,
		next:   next,
		signer: newDefaultSigner(config),

View on GitHub (pinned to 01ffac6f24)