seed: coerce YAML scalars to strings
1 changed file +5 −2
modified
apps/api/src/internetpressure/registry.py
+5 −2
@@ -262,8 +262,11 @@ async def seed(*, targets: bool = True, services: bool = True, probes: bool = Tr | |||||
| 262 | log.info("seed: %d fragment entries skipped as duplicates (id or host)", skipped) | 262 | log.info("seed: %d fragment entries skipped as duplicates (id or host)", skipped) | ||
| 263 | for t in all_targets: | 263 | for t in all_targets: | ||
| 264 | row = { | 264 | row = { | ||
| 265 | − "target_id": str(t["id"]), "name": str(t["name"]), "hostname": str(t["host"]), "url": t.get("url"), "ip": t.get("ip"), | 265 | + "target_id": str(t["id"]), "name": str(t["name"]), "hostname": str(t["host"]), | ||
| 266 | − "port": t.get("port", 443), "category": t["cat"], "provider": t.get("provider"), "service_id": t.get("svc"), | 266 | + "url": None if t.get("url") is None else str(t["url"]), "ip": None if t.get("ip") is None else str(t["ip"]), | ||
| 267 | + "port": t.get("port", 443), "category": str(t["cat"]), | ||||
| 268 | + "provider": None if t.get("provider") is None else str(t["provider"]), | ||||
| 269 | + "service_id": None if t.get("svc") is None else str(t["svc"]), | ||||
| 267 | "country": t.get("cc"), "region": regions.region_of_country(t.get("cc")), | 270 | "country": t.get("cc"), "region": regions.region_of_country(t.get("cc")), | ||
| 268 | "importance": t.get("imp", defaults.get("imp", 3)), "tier": t.get("tier", defaults.get("tier", 2)), | 271 | "importance": t.get("imp", defaults.get("imp", 3)), "tier": t.get("tier", defaults.get("tier", 2)), | ||
| 269 | "checks": t.get("checks", defaults.get("checks", ["http", "dns", "ping"])), | 272 | "checks": t.get("checks", defaults.get("checks", ["http", "dns", "ping"])), | ||
| 270 | 273 | ||||