grafana/k6 · error

invalid longitude "%.2f": precondition -180 <= LONGITUDE <=…

Error message

invalid longitude "%.2f": precondition -180 <= LONGITUDE <= 180 failed

What it means

Geolocation.Validate rejected the geolocation options passed to browser.newContext(): longitude is outside [-180, 180]. The invalid value is echoed with two decimals; the precondition mirrors Chrome DevTools Protocol constraints.

Solutions

  1. Use a longitude in [-180, 180], e.g. geolocation: {longitude: 12.4924, latitude: 41.8902, accuracy: 100}
  2. Swap latitude/longitude if values look transposed
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

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

	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
}

// GrantPermissionsOptions is used by BrowserContext.GrantPermissions.
type GrantPermissionsOptions struct {
	Origin string
}

View on GitHub (pinned to 01ffac6f24)