{"record":{"id":"05c5aae4f4b74561","repo":"grafana/k6","slug":"invalid-longitude-2f-precondition-180-lon","errorCode":null,"errorMessage":"invalid longitude \"%.2f\": precondition -180 <= LONGITUDE <= 180 failed","messagePattern":"invalid longitude \"%\\.2f\": precondition -180 <= LONGITUDE <= 180 failed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/browser_context_options.go","lineNumber":76,"sourceCode":"\tServer string `js:\"server\"`\n\tBypass string `js:\"bypass\"`\n}\n\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":58,"sourceCodeEnd":91,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/browser_context_options.go#L58-L91","documentation":"Validation error from Geolocation.Validate: the longitude supplied for geolocation emulation is outside the valid range [-180, 180]. k6 enforces the same precondition Playwright documents before sending the Emulation.setGeolocationOverride CDP command; the offending value is printed with two decimals.","triggerScenarios":"browser.newContext({ geolocation: { longitude: 200 } }) or context.setGeolocation({ longitude: -181, ... }); any numeric input beyond the range, including values produced by bad math (e.g. degrees+radians mixups or sign errors).","commonSituations":"Tests passing coordinates in radians where degrees were expected (values like 3.14 are legal but wrong; multiplying wrong can push past 180); data-driven location lists containing typos (200 instead of 20.0); unit mistakes copying from datasets that use [latitude, longitude] ordering.","solutions":["Correct the longitude to a value in [-180, 180], e.g. 139.69 for Tokyo.","Validate coordinates before passing them when they come from external data.","Double-check you are not feeding radians or swapping latitude/longitude fields."],"exampleFix":"// before\ncontext.setGeolocation({ latitude: 35.68, longitude: 13969 }); // typo: *100\n\n// after\ncontext.setGeolocation({ latitude: 35.68, longitude: 139.69 });","handlingStrategy":"validation","validationCode":"function isValidLongitude(v) {\n  return Number.isFinite(v) && v >= -180 && v <= 180;\n}\nif (!isValidLongitude(geo.longitude)) {\n  throw new Error('longitude must be between -180 and 180 degrees');\n}\ncontext.setGeolocation(geo);","typeGuard":"function isValidGeolocation(g) {\n  return Number.isFinite(g.longitude) && g.longitude >= -180 && g.longitude <= 180 &&\n         Number.isFinite(g.latitude) && g.latitude >= -90 && g.latitude <= 90 &&\n         (g.accuracy == null || (Number.isFinite(g.accuracy) && g.accuracy >= 0));\n}","tryCatchPattern":null,"preventionTips":["Validate both coordinate ranges before calling setGeolocation/newContext({geolocation}).","Confirm your data source uses degrees, not radians.","Check for swapped latitude/longitude when values are near ±180."],"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"}