{"record":{"id":"f336d992563d5022","repo":"koala73/worldmonitor","slug":"bbox-invalid-sw-corner-outside-lat-lon-domain-9","errorCode":null,"errorMessage":"bbox invalid: sw corner outside lat/lon domain (-90..90 / -180..180)","messagePattern":"bbox invalid: sw corner outside lat/lon domain \\(-90\\.\\.90 / -180\\.\\.180\\)","errorType":"validation","errorClass":"BboxValidationError","httpStatus":400,"severity":"error","filePath":"server/worldmonitor/maritime/v1/get-vessel-snapshot.ts","lineNumber":311,"sourceCode":"// Prefer BboxValidationError for new code.\nexport const BboxTooLargeError = BboxValidationError;\n\nfunction isValidLatLon(lat: number, lon: number): boolean {\n  return (\n    Number.isFinite(lat) && Number.isFinite(lon) &&\n    lat >= -90 && lat <= 90 && lon >= -180 && lon <= 180\n  );\n}\n\nfunction extractAndValidateBbox(req: GetVesselSnapshotRequest): { swLat: number; swLon: number; neLat: number; neLon: number } | null {\n  const sw = { lat: Number(req.swLat), lon: Number(req.swLon) };\n  const ne = { lat: Number(req.neLat), lon: Number(req.neLon) };\n  // All zeroes (the default for unset proto doubles) → no bbox.\n  if (sw.lat === 0 && sw.lon === 0 && ne.lat === 0 && ne.lon === 0) {\n    return null;\n  }\n  if (!isValidLatLon(sw.lat, sw.lon)) {\n    throw new BboxValidationError('sw corner outside lat/lon domain (-90..90 / -180..180)');\n  }\n  if (!isValidLatLon(ne.lat, ne.lon)) {\n    throw new BboxValidationError('ne corner outside lat/lon domain (-90..90 / -180..180)');\n  }\n  if (sw.lat > ne.lat || sw.lon > ne.lon) {\n    throw new BboxValidationError('sw corner must be south-west of ne corner');\n  }\n  if (ne.lat - sw.lat > MAX_BBOX_DEGREES || ne.lon - sw.lon > MAX_BBOX_DEGREES) {\n    throw new BboxValidationError(`each dimension must be ≤ ${MAX_BBOX_DEGREES} degrees`);\n  }\n  return { swLat: sw.lat, swLon: sw.lon, neLat: ne.lat, neLon: ne.lon };\n}\n\nexport async function getVesselSnapshot(\n  _ctx: ServerContext,\n  req: GetVesselSnapshotRequest,\n): Promise<GetVesselSnapshotResponse> {\n  try {","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/koala73/worldmonitor/blob/eeab0a219fce0f02a00603b532dbae9041b934ac/server/worldmonitor/maritime/v1/get-vessel-snapshot.ts#L293-L329","documentation":"Bbox validation in extractAndValidateBbox (vessel snapshot): the southwest corner lat/lon is non-finite or outside the geographic domain (lat -90..90, lon -180..180). An all-zero bbox is treated as 'no bbox', so reaching this throw means a genuinely invalid sw corner was supplied in the request.","triggerScenarios":"Thrown at server/worldmonitor/maritime/v1/get-vessel-snapshot.ts:311 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the swLat/swLon values in the request to finite values within the domain","Validate bbox corners client-side (map bounds) before requesting a vessel snapshot"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"eeab0a219fce0f02a00603b532dbae9041b934ac","analyzedAt":"2026-08-21T16:51:25.751Z","contentChangedAt":"2026-08-21T16:51:25.751Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}