{"record":{"id":"3e02c4357f1807eb","repo":"openclaw/openclaw","slug":"accuracy-must-be-non-negative","errorCode":null,"errorMessage":"accuracy must be non-negative.","messagePattern":"accuracy must be non-negative\\.","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"extensions/browser/src/browser/routes/agent.storage.ts","lineNumber":167,"sourceCode":"  if (clear) {\n    return { clear };\n  }\n  const origin = readOptionalHttpOrigin(body.origin);\n  const latitude = assertRange(\n    readRouteFiniteNumber(body.latitude, \"latitude\"),\n    \"latitude\",\n    -90,\n    90,\n  );\n  const longitude = assertRange(\n    readRouteFiniteNumber(body.longitude, \"longitude\"),\n    \"longitude\",\n    -180,\n    180,\n  );\n  const accuracy = readRouteFiniteNumber(body.accuracy, \"accuracy\");\n  if (accuracy !== undefined && accuracy < 0) {\n    throw new Error(\"accuracy must be non-negative.\");\n  }\n  if (!clear && (latitude === undefined || longitude === undefined)) {\n    throw new Error(\"latitude and longitude are required (or set clear=true)\");\n  }\n  return { clear, latitude, longitude, accuracy, origin };\n}\n\n/** Register storage and browser-context mutation endpoints. */\nexport function registerBrowserAgentStorageRoutes(\n  app: BrowserRouteRegistrar,\n  ctx: BrowserRouteContext,\n) {\n  app.get(\"/cookies\", async (req, res) => {\n    const targetId = resolveTargetIdFromQuery(req.query);\n    await withPlaywrightRouteContext({\n      req,\n      res,\n      ctx,","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/openclaw/openclaw/blob/01804a75319da4b69c9ab98ceaa30477e22b8c0b/extensions/browser/src/browser/routes/agent.storage.ts#L149-L185","documentation":"Thrown by parseGeolocationOptions when overriding the browser geolocation context. The 'accuracy' field (read first via readRouteFiniteNumber, so it must already be finite) is rejected if it is less than zero, because geolocation accuracy is expressed in meters and is physically non-negative. This is a request-body validation guard for the context mutation route, not a runtime/browser-state error.","triggerScenarios":"POST to a browser agent storage/context-mutation endpoint with body.accuracy set to a negative number (e.g. -1) while body.clear is falsy. Trigger fires only when accuracy is a real number (non-null); undefined accuracy is allowed.","commonSituations":"Using -1 as an 'unset' sentinel for accuracy; sign mistakes when copying coordinates; fuzz/testing with arbitrary negative values; client code that defaults unset numerics to -1.","solutions":["Omit the accuracy field entirely if you do not need to override it.","Send a non-negative finite number for accuracy (e.g. 10).","If the intent is to remove an existing geolocation override, send clear=true instead of a negative accuracy."],"exampleFix":"// before\nfetch('/browser/agent/storage/geolocation', { method: 'POST', body: JSON.stringify({ latitude: 37.77, longitude: -122.41, accuracy: -1 }) });\n// after\nfetch('/browser/agent/storage/geolocation', { method: 'POST', body: JSON.stringify({ latitude: 37.77, longitude: -122.41, accuracy: 10 }) });","handlingStrategy":"validation","validationCode":"function safeAccuracy(value: unknown): number | undefined {\n  if (value == null) return undefined;\n  const n = Number(value);\n  if (!Number.isFinite(n)) {\n    throw new Error('accuracy must be a finite number');\n  }\n  if (n < 0) {\n    throw new Error('accuracy must be non-negative');\n  }\n  return n;\n}\n// build body: const accuracy = safeAccuracy(raw.accuracy);","typeGuard":"function isValidAccuracy(v: unknown): v is number {\n  return typeof v === 'number' && Number.isFinite(v) && v >= 0;\n}","tryCatchPattern":null,"preventionTips":["Normalize 'unset' numerics to undefined rather than -1 before posting.","Validate accuracy >= 0 client-side with the same finite-number check the server uses.","Use clear=true to remove an override instead of sending sentinel values."],"tags":["validation","geolocation","browser-route","request-body"],"backgroundTag":null,"analyzedSha":"01804a75319da4b69c9ab98ceaa30477e22b8c0b","analyzedAt":"2026-08-12T04:37:58.197Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}