{"record":{"id":"46244b7fda5d4047","repo":"grafana/k6","slug":"invalid-latitude-2f-precondition-90-latit","errorCode":null,"errorMessage":"invalid latitude \"%.2f\": precondition -90 <= LATITUDE <= 90 failed","messagePattern":"invalid latitude \"%\\.2f\": precondition -90 <= LATITUDE <= 90 failed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/browser_context_options.go","lineNumber":79,"sourceCode":"\n// Validate validates the [ProxyOptions].\nfunc (p *ProxyOptions) Validate() error {\n\tif p == nil {\n\t\treturn nil\n\t}\n\tif strings.TrimSpace(p.Server) == \"\" {\n\t\treturn fmt.Errorf(\"proxy.server must be set\")\n\t}\n\treturn nil\n}\n\n// Validate validates the [Geolocation].\nfunc (g *Geolocation) Validate() error {\n\tif g.Longitude < -180 || g.Longitude > 180 {\n\t\treturn fmt.Errorf(`invalid longitude \"%.2f\": precondition -180 <= LONGITUDE <= 180 failed`, g.Longitude)\n\t}\n\tif g.Latitude < -90 || g.Latitude > 90 {\n\t\treturn fmt.Errorf(`invalid latitude \"%.2f\": precondition -90 <= LATITUDE <= 90 failed`, g.Latitude)\n\t}\n\tif g.Accuracy < 0 {\n\t\treturn fmt.Errorf(`invalid accuracy \"%.2f\": precondition 0 <= ACCURACY failed`, g.Accuracy)\n\t}\n\treturn nil\n}\n\n// GrantPermissionsOptions is used by BrowserContext.GrantPermissions.\ntype GrantPermissionsOptions struct {\n\tOrigin string\n}\n","sourceCodeStart":61,"sourceCodeEnd":91,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/browser_context_options.go#L61-L91","documentation":"Validation error from Geolocation.Validate: the latitude supplied for geolocation emulation is outside the valid range [-90, 90]. As with longitude, k6 checks the precondition before invoking the CDP emulation command and rejects the whole call, printing the invalid latitude.","triggerScenarios":"browser.newContext({ geolocation: { latitude: 95 } }) or context.setGeolocation({ latitude: -120 }); any latitude beyond the poles' ±90 limit.","commonSituations":"Swapped latitude/longitude arguments (a longitude like 139 fed as latitude exceeds 90 immediately — this is the most common cause); typos in coordinate fixtures; generated data with sign or magnitude errors.","solutions":["Correct the latitude to [-90, 90] (e.g. 35.68).","If the value looks like a valid longitude (>90), you almost certainly swapped the latitude and longitude fields — swap them back.","Validate coordinates from data files before use."],"exampleFix":"// before\ncontext.setGeolocation({ latitude: 139.69, longitude: 35.68 }); // fields swapped\n\n// after\ncontext.setGeolocation({ latitude: 35.68, longitude: 139.69 });","handlingStrategy":"validation","validationCode":"function isValidLatitude(v) {\n  return Number.isFinite(v) && v >= -90 && v <= 90;\n}\nif (!isValidLatitude(geo.latitude)) {\n  throw new Error('latitude must be between -90 and 90 degrees (are lat/lng swapped?)');\n}\ncontext.setGeolocation(geo);","typeGuard":"function isValidLatitude(v) {\n  return Number.isFinite(v) && v >= -90 && v <= 90;\n}","tryCatchPattern":null,"preventionTips":["A latitude over ±90 almost always means swapped lat/lng fields — check ordering first.","Validate coordinates from data files against both ranges in CI.","Keep coordinate fixtures in {latitude, longitude} key form to avoid positional mistakes."],"tags":["geolocation","validation","browser-context"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}