{"record":{"id":"732d92cec2082f4e","repo":"puppeteer/puppeteer","slug":"invalid-latitude-latitude-precondition-90-732d92","errorCode":null,"errorMessage":"Invalid latitude \"${latitude}\": precondition -90 <= LATITUDE <= 90 failed.","messagePattern":"Invalid latitude \"(.+?)\": precondition -90 <= LATITUDE <= 90 failed\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/puppeteer-core/src/cdp/EmulationManager.ts","lineNumber":562,"sourceCode":"      state.geoLocation\n        ? {\n            longitude: state.geoLocation.longitude,\n            latitude: state.geoLocation.latitude,\n            accuracy: state.geoLocation.accuracy,\n          }\n        : undefined,\n    );\n  }\n\n  async setGeolocation(options: GeolocationOptions): Promise<void> {\n    const {longitude, latitude, accuracy = 0} = options;\n    if (longitude < -180 || longitude > 180) {\n      throw new Error(\n        `Invalid longitude \"${longitude}\": precondition -180 <= LONGITUDE <= 180 failed.`,\n      );\n    }\n    if (latitude < -90 || latitude > 90) {\n      throw new Error(\n        `Invalid latitude \"${latitude}\": precondition -90 <= LATITUDE <= 90 failed.`,\n      );\n    }\n    if (accuracy < 0) {\n      throw new Error(\n        `Invalid accuracy \"${accuracy}\": precondition 0 <= ACCURACY failed.`,\n      );\n    }\n    await this.#geoLocationState.setState({\n      active: true,\n      geoLocation: {\n        longitude,\n        latitude,\n        accuracy,\n      },\n    });\n  }\n","sourceCodeStart":544,"sourceCodeEnd":580,"githubUrl":"https://github.com/puppeteer/puppeteer/blob/d484e21c17f6023826fefdcdeeb553e04a7aaed8/packages/puppeteer-core/src/cdp/EmulationManager.ts#L544-L580","documentation":"Thrown by EmulationManager.setGeolocation when the latitude value is outside the [-90, 90] range. Client-side precondition mirroring the Emulation.setGeolocationOverride CDP check, raised before the command is sent so the offending value is obvious.","triggerScenarios":"Calling page.setGeolocation with latitude < -90 or > 90; magnitude error from a malformed fixture; sign confusion on southern latitudes.","commonSituations":"Coordinates pulled from external data without bounds checking; tests using extreme values; copy-paste of a latitude where a longitude was expected (longitudes can exceed +/-90).","solutions":["Validate latitude is within [-90, 90] before calling setGeolocation.","Double-check that you are not passing a longitude (>90) into the latitude field.","Sanitize input coordinates from untrusted sources with a clamp helper.","Add a unit test on your coordinate-building code to catch out-of-range values."],"exampleFix":"// before\nawait page.setGeolocation({ longitude: -73, latitude: 120 }); // throws\n\n// after: validate\nconst latitude = clamp(rawLat, -90, 90);\nawait page.setGeolocation({ longitude: -73, latitude });","handlingStrategy":"validation","validationCode":"if (!Number.isFinite(latitude) || latitude < -90 || latitude > 90) {\n  throw new Error(`latitude out of range: ${latitude}`);\n}","typeGuard":"function isValidLatitude(v: unknown): v is number {\n  return typeof v === 'number' && Number.isFinite(v) && v >= -90 && v <= 90;\n}","tryCatchPattern":null,"preventionTips":["Validate latitude to [-90, 90].","Make sure you are not passing a longitude into the latitude field.","Clamp untrusted coordinate sources."],"tags":["emulation","geolocation","validation","precondition"],"backgroundTag":null,"analyzedSha":"d484e21c17f6023826fefdcdeeb553e04a7aaed8","analyzedAt":"2026-08-12T06:33:19.665Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}