{"record":{"id":"b74cd336a4adf903","repo":"microsoft/playwright","slug":"geolocation-latitude-precondition-90-latitude","errorCode":null,"errorMessage":"geolocation.latitude: precondition -90 <= LATITUDE <= 90 failed.","messagePattern":"geolocation\\.latitude: precondition -90 <= LATITUDE <= 90 failed\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/server/browserContext.ts","lineNumber":790,"sourceCode":"  if (options.proxy)\n    options.proxy = normalizeProxySettings(options.proxy);\n  verifyGeolocation(options.geolocation);\n}\n\nexport function findMatchingHttpCredentials(credentials: HttpCredentials[] | undefined, url: string): HttpCredentials | undefined {\n  const origin = new URL(url).origin.toLowerCase();\n  return credentials?.find(c => !c.origin || c.origin.toLowerCase() === origin);\n}\n\nexport function verifyGeolocation(geolocation?: types.Geolocation): asserts geolocation is types.Geolocation {\n  if (!geolocation)\n    return;\n  geolocation.accuracy = geolocation.accuracy || 0;\n  const { longitude, latitude, accuracy } = geolocation;\n  if (longitude < -180 || longitude > 180)\n    throw new Error(`geolocation.longitude: precondition -180 <= LONGITUDE <= 180 failed.`);\n  if (latitude < -90 || latitude > 90)\n    throw new Error(`geolocation.latitude: precondition -90 <= LATITUDE <= 90 failed.`);\n  if (accuracy < 0)\n    throw new Error(`geolocation.accuracy: precondition 0 <= ACCURACY failed.`);\n}\n\nexport function verifyClientCertificates(clientCertificates?: types.BrowserContextOptions['clientCertificates']) {\n  if (!clientCertificates)\n    return;\n  for (const cert of clientCertificates) {\n    if (!cert.origin)\n      throw new Error(`clientCertificates.origin is required`);\n    if (!cert.cert && !cert.key && !cert.passphrase && !cert.pfx)\n      throw new Error('None of cert, key, passphrase or pfx is specified');\n    if (cert.cert && !cert.key)\n      throw new Error('cert is specified without key');\n    if (!cert.cert && cert.key)\n      throw new Error('key is specified without cert');\n    if (cert.pfx && (cert.cert || cert.key))\n      throw new Error('pfx is specified together with cert, key or passphrase');","sourceCodeStart":772,"sourceCodeEnd":808,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/server/browserContext.ts#L772-L808","documentation":"`verifyGeolocation` enforces latitude within [-90, 90]. Out-of-range values throw with this precondition-style message.","triggerScenarios":"`context.setGeolocation({ longitude: 0, latitude: 95 })` or `newContext({ geolocation: { latitude: -120 } })`.","commonSituations":"Sign/typo errors in coordinates; unverified data from external sources; latitude/longitude swapped (longitude values can exceed ±90).","solutions":["Clamp latitude to [-90, 90] before passing","Double-check that latitude and longitude aren't swapped","Validate input ranges before calling setGeolocation"],"exampleFix":"// before\nawait context.setGeolocation({ longitude: 0, latitude: 120 });\n\n// after\nawait context.setGeolocation({ longitude: 0, latitude: Math.max(-90, Math.min(90, 120)) });","handlingStrategy":"validation","validationCode":"function validateLat(lat: number): number {\n  if (lat < -90 || lat > 90) throw new Error(`latitude out of range: ${lat}`);\n  return lat;\n}\nawait context.setGeolocation({ longitude: lon, latitude: validateLat(lat) });","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clamp/validate latitude to [-90, 90]","Double-check lat/lon aren't swapped (lon can exceed ±90)","Validate coordinates at the data boundary"],"tags":["geolocation","validation","config"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}