Validate geofence radius to be positive

This commit is contained in:
jkingsman
2026-03-26 17:20:13 -07:00
parent 650a24a68c
commit ac5e71d6f2
2 changed files with 93 additions and 0 deletions
+8
View File
@@ -308,6 +308,14 @@ def _validate_map_upload_config(config: dict) -> None:
# Persist the cleaned value (empty string means use the module default)
config["api_url"] = api_url
config["dry_run"] = bool(config.get("dry_run", True))
config["geofence_enabled"] = bool(config.get("geofence_enabled", False))
try:
radius = float(config.get("geofence_radius_km", 0) or 0)
except (TypeError, ValueError):
raise HTTPException(status_code=400, detail="geofence_radius_km must be a number") from None
if radius < 0:
raise HTTPException(status_code=400, detail="geofence_radius_km must be >= 0")
config["geofence_radius_km"] = radius
def _enforce_scope(config_type: str, scope: dict) -> dict: