grafana/k6 · error

proxy.server must be set

Error message

proxy.server must be set

What it means

browserContext was created with a proxy options object whose server field is empty/whitespace. ProxyOptions.Validate requires server to be set whenever a proxy block is present; the faulting input is the {proxy:{...}} part of newContext options.

Solutions

  1. Set a server, e.g. proxy: {server: 'http://myproxy:8080'}
  2. Remove the proxy block if no proxy is needed
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/common/browser_context_options.go:68 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/0af880d355edcbc6. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/common/browser_context_options.go:68

type Geolocation struct {
	Latitude  float64 `js:"latitude"`
	Longitude float64 `js:"longitude"`
	Accuracy  float64 `js:"accuracy"`
}

// ProxyOptions represents proxy configuration for a browser context.
type ProxyOptions struct {
	Server string `js:"server"`
	Bypass string `js:"bypass"`
}

// Validate validates the [ProxyOptions].
func (p *ProxyOptions) Validate() error {
	if p == nil {
		return nil
	}
	if strings.TrimSpace(p.Server) == "" {
		return fmt.Errorf("proxy.server must be set")
	}
	return nil
}

// Validate validates the [Geolocation].
func (g *Geolocation) Validate() error {
	if g.Longitude < -180 || g.Longitude > 180 {
		return fmt.Errorf(`invalid longitude "%.2f": precondition -180 <= LONGITUDE <= 180 failed`, g.Longitude)
	}
	if g.Latitude < -90 || g.Latitude > 90 {
		return fmt.Errorf(`invalid latitude "%.2f": precondition -90 <= LATITUDE <= 90 failed`, g.Latitude)
	}
	if g.Accuracy < 0 {
		return fmt.Errorf(`invalid accuracy "%.2f": precondition 0 <= ACCURACY failed`, g.Accuracy)
	}
	return nil
}

View on GitHub (pinned to 01ffac6f24)