test_support_helpers.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. """Unit tests for support module helper functions.
  2. Tests _anonymize_mqtt_broker, _check_port, _get_container_memory_limit,
  3. _format_bytes, and _collect_support_info diagnostic sections.
  4. """
  5. import asyncio
  6. import tempfile
  7. from pathlib import Path
  8. from unittest.mock import AsyncMock, MagicMock, patch
  9. import pytest
  10. class TestApplyLogLevel:
  11. """Tests for _apply_log_level() debug noise suppression."""
  12. def test_debug_mode_suppresses_sqlalchemy_to_warning(self):
  13. """Verify sqlalchemy.engine is set to WARNING (not INFO) in debug mode."""
  14. import logging
  15. from backend.app.api.routes.support import _apply_log_level
  16. _apply_log_level(True)
  17. assert logging.getLogger("sqlalchemy.engine").level == logging.WARNING
  18. def test_debug_mode_suppresses_aiosqlite(self):
  19. """Verify aiosqlite is set to WARNING in debug mode to prevent cursor noise."""
  20. import logging
  21. from backend.app.api.routes.support import _apply_log_level
  22. _apply_log_level(True)
  23. assert logging.getLogger("aiosqlite").level == logging.WARNING
  24. def test_debug_mode_keeps_httpx_pinned_to_warning(self):
  25. """httpx/httpcore must stay at WARNING even in debug mode — at INFO/DEBUG
  26. they log full request URLs, leaking webhook tokens (Discord etc.)."""
  27. import logging
  28. from backend.app.api.routes.support import _apply_log_level
  29. _apply_log_level(True)
  30. assert logging.getLogger("httpcore").level == logging.WARNING
  31. assert logging.getLogger("httpx").level == logging.WARNING
  32. def test_non_debug_mode_suppresses_all_noisy_loggers(self):
  33. """Verify all noisy loggers are set to WARNING in non-debug mode."""
  34. import logging
  35. from backend.app.api.routes.support import _apply_log_level
  36. _apply_log_level(False)
  37. assert logging.getLogger("sqlalchemy.engine").level == logging.WARNING
  38. assert logging.getLogger("httpcore").level == logging.WARNING
  39. assert logging.getLogger("httpx").level == logging.WARNING
  40. assert logging.getLogger("paho.mqtt").level == logging.WARNING
  41. class TestAnonymizeMqttBroker:
  42. """Tests for _anonymize_mqtt_broker()."""
  43. def test_empty_string(self):
  44. from backend.app.api.routes.support import _anonymize_mqtt_broker
  45. assert _anonymize_mqtt_broker("") == ""
  46. def test_ipv4_address(self):
  47. from backend.app.api.routes.support import _anonymize_mqtt_broker
  48. assert _anonymize_mqtt_broker("192.168.1.100") == "[IP]"
  49. def test_ipv6_address(self):
  50. from backend.app.api.routes.support import _anonymize_mqtt_broker
  51. assert _anonymize_mqtt_broker("::1") == "[IP]"
  52. def test_hostname_with_domain(self):
  53. from backend.app.api.routes.support import _anonymize_mqtt_broker
  54. assert _anonymize_mqtt_broker("mqtt.example.com") == "*.example.com"
  55. def test_hostname_with_subdomain(self):
  56. from backend.app.api.routes.support import _anonymize_mqtt_broker
  57. assert _anonymize_mqtt_broker("broker.mqtt.example.com") == "*.example.com"
  58. def test_single_part_hostname(self):
  59. from backend.app.api.routes.support import _anonymize_mqtt_broker
  60. assert _anonymize_mqtt_broker("localhost") == "localhost"
  61. class TestCheckPort:
  62. """Tests for _check_port()."""
  63. @pytest.mark.asyncio
  64. @pytest.mark.unit
  65. async def test_reachable_port(self):
  66. from backend.app.api.routes.support import _check_port
  67. # Mock a successful connection
  68. mock_writer = AsyncMock()
  69. mock_writer.close = MagicMock()
  70. mock_writer.wait_closed = AsyncMock()
  71. with patch("backend.app.api.routes.support.asyncio.open_connection", return_value=(AsyncMock(), mock_writer)):
  72. result = await _check_port("192.168.1.1", 8883, timeout=1.0)
  73. assert result is True
  74. @pytest.mark.asyncio
  75. @pytest.mark.unit
  76. async def test_unreachable_port(self):
  77. from backend.app.api.routes.support import _check_port
  78. with (
  79. patch(
  80. "backend.app.api.routes.support.asyncio.open_connection",
  81. side_effect=ConnectionRefusedError,
  82. ),
  83. patch(
  84. "backend.app.api.routes.support.asyncio.wait_for",
  85. side_effect=ConnectionRefusedError,
  86. ),
  87. ):
  88. result = await _check_port("192.168.1.1", 8883, timeout=1.0)
  89. assert result is False
  90. @pytest.mark.asyncio
  91. @pytest.mark.unit
  92. async def test_timeout(self):
  93. from backend.app.api.routes.support import _check_port
  94. with patch(
  95. "backend.app.api.routes.support.asyncio.wait_for",
  96. side_effect=asyncio.TimeoutError,
  97. ):
  98. result = await _check_port("192.168.1.1", 8883, timeout=0.1)
  99. assert result is False
  100. class TestGetContainerMemoryLimit:
  101. """Tests for _get_container_memory_limit()."""
  102. def test_cgroup_v2_with_limit(self):
  103. from backend.app.api.routes.support import _get_container_memory_limit
  104. with tempfile.TemporaryDirectory() as tmpdir:
  105. v2_path = Path(tmpdir) / "memory.max"
  106. v2_path.write_text("1073741824\n")
  107. with patch("backend.app.api.routes.support.Path") as mock_path:
  108. # v2 path exists with value
  109. v2_mock = MagicMock()
  110. v2_mock.exists.return_value = True
  111. v2_mock.read_text.return_value = "1073741824\n"
  112. v1_mock = MagicMock()
  113. v1_mock.exists.return_value = False
  114. mock_path.side_effect = lambda p: v2_mock if "memory.max" in p else v1_mock
  115. result = _get_container_memory_limit()
  116. assert result == 1073741824
  117. def test_cgroup_v2_unlimited(self):
  118. from backend.app.api.routes.support import _get_container_memory_limit
  119. with patch("backend.app.api.routes.support.Path") as mock_path:
  120. v2_mock = MagicMock()
  121. v2_mock.exists.return_value = True
  122. v2_mock.read_text.return_value = "max\n"
  123. v1_mock = MagicMock()
  124. v1_mock.exists.return_value = False
  125. mock_path.side_effect = lambda p: v2_mock if "memory.max" in p else v1_mock
  126. result = _get_container_memory_limit()
  127. assert result is None
  128. def test_no_cgroup_files(self):
  129. from backend.app.api.routes.support import _get_container_memory_limit
  130. with patch("backend.app.api.routes.support.Path") as mock_path:
  131. mock_instance = MagicMock()
  132. mock_instance.exists.return_value = False
  133. mock_path.return_value = mock_instance
  134. result = _get_container_memory_limit()
  135. assert result is None
  136. class TestFormatBytes:
  137. """Tests for _format_bytes()."""
  138. def test_bytes(self):
  139. from backend.app.api.routes.support import _format_bytes
  140. assert _format_bytes(500) == "500 B"
  141. def test_kilobytes(self):
  142. from backend.app.api.routes.support import _format_bytes
  143. assert _format_bytes(2048) == "2.0 KB"
  144. def test_megabytes(self):
  145. from backend.app.api.routes.support import _format_bytes
  146. assert _format_bytes(10 * 1024 * 1024) == "10.0 MB"
  147. def test_gigabytes(self):
  148. from backend.app.api.routes.support import _format_bytes
  149. assert _format_bytes(2 * 1024 * 1024 * 1024) == "2.00 GB"
  150. def test_zero(self):
  151. from backend.app.api.routes.support import _format_bytes
  152. assert _format_bytes(0) == "0 B"
  153. class TestSanitizeLogContent:
  154. """Tests for _sanitize_log_content() redaction."""
  155. def test_ipv4_addresses_redacted(self):
  156. """IPv4 addresses in log lines are replaced with [IP]."""
  157. from backend.app.api.routes.support import _sanitize_log_content
  158. content = "2024-01-15 Connected to printer at 192.168.1.100 on port 8883"
  159. result = _sanitize_log_content(content)
  160. assert "192.168.1.100" not in result
  161. assert "[IP]" in result
  162. assert "on port 8883" in result
  163. def test_multiple_ipv4_addresses_redacted(self):
  164. """Multiple different IPs in the same line are all redacted."""
  165. from backend.app.api.routes.support import _sanitize_log_content
  166. content = "Proxy 10.0.0.1 -> 192.168.1.50"
  167. result = _sanitize_log_content(content)
  168. assert result == "Proxy [IP] -> [IP]"
  169. def test_firmware_versions_with_leading_zeros_preserved(self):
  170. """Firmware versions like 01.09.01.00 have leading zeros and should NOT be redacted."""
  171. from backend.app.api.routes.support import _sanitize_log_content
  172. content = "Firmware version: 01.09.01.00"
  173. result = _sanitize_log_content(content)
  174. assert "01.09.01.00" in result
  175. def test_firmware_version_mixed_with_ip(self):
  176. """Firmware versions preserved while real IPs are redacted in the same line."""
  177. from backend.app.api.routes.support import _sanitize_log_content
  178. content = "Printer at 192.168.1.5 running firmware 01.07.02.00"
  179. result = _sanitize_log_content(content)
  180. assert "192.168.1.5" not in result
  181. assert "01.07.02.00" in result
  182. assert "[IP] running firmware 01.07.02.00" in result
  183. def test_printer_ip_from_sensitive_strings(self):
  184. """Printer IPs in sensitive_strings are replaced before regex pass."""
  185. from backend.app.api.routes.support import _sanitize_log_content
  186. content = "Connecting to 192.168.1.100"
  187. result = _sanitize_log_content(content, sensitive_strings={"192.168.1.100": "[IP]"})
  188. assert result == "Connecting to [IP]"
  189. def test_edge_case_zero_ip(self):
  190. """0.0.0.0 is a valid IP and should be redacted."""
  191. from backend.app.api.routes.support import _sanitize_log_content
  192. content = "Binding to 0.0.0.0"
  193. result = _sanitize_log_content(content)
  194. assert result == "Binding to [IP]"
  195. def test_edge_case_broadcast_ip(self):
  196. """255.255.255.255 is a valid IP and should be redacted."""
  197. from backend.app.api.routes.support import _sanitize_log_content
  198. content = "Broadcast to 255.255.255.255"
  199. result = _sanitize_log_content(content)
  200. assert result == "Broadcast to [IP]"
  201. def test_invalid_octet_not_redacted(self):
  202. """Octets >255 are not valid IPs and should not be redacted."""
  203. from backend.app.api.routes.support import _sanitize_log_content
  204. content = "Value 999.999.999.999"
  205. result = _sanitize_log_content(content)
  206. assert "999.999.999.999" in result
  207. def test_existing_serial_redaction_still_works(self):
  208. """Serial number redaction still functions alongside IP redaction."""
  209. from backend.app.api.routes.support import _sanitize_log_content
  210. content = "Printer 01SABCDEF1234 at 10.0.0.5"
  211. result = _sanitize_log_content(content)
  212. assert "[SERIAL]" in result
  213. assert "[IP]" in result
  214. assert "01SABCDEF1234" not in result
  215. assert "10.0.0.5" not in result
  216. def test_existing_email_redaction_still_works(self):
  217. """Email redaction still functions alongside IP redaction."""
  218. from backend.app.api.routes.support import _sanitize_log_content
  219. content = "User user@example.com from 172.16.0.1"
  220. result = _sanitize_log_content(content)
  221. assert "[EMAIL]" in result
  222. assert "[IP]" in result
  223. def test_existing_path_redaction_still_works(self):
  224. """Path redaction still functions alongside IP redaction."""
  225. from backend.app.api.routes.support import _sanitize_log_content
  226. content = "Config at /home/john/config.yaml from 192.168.0.1"
  227. result = _sanitize_log_content(content)
  228. assert "/home/[user]/" in result
  229. assert "[IP]" in result
  230. class TestCollectSupportInfo:
  231. """Tests for _collect_support_info() new diagnostic sections."""
  232. @pytest.mark.asyncio
  233. @pytest.mark.unit
  234. async def test_environment_has_timezone(self):
  235. """Verify environment section includes timezone."""
  236. from backend.app.api.routes.support import _collect_support_info
  237. with (
  238. patch("backend.app.api.routes.support.is_running_in_docker", return_value=False),
  239. patch("backend.app.api.routes.support.async_session") as mock_session_ctx,
  240. patch("backend.app.api.routes.support.printer_manager") as mock_pm,
  241. patch("backend.app.api.routes.support.get_network_interfaces", return_value=[]),
  242. patch("backend.app.api.routes.support.ws_manager") as mock_ws,
  243. patch.dict("os.environ", {"TZ": "America/New_York"}),
  244. ):
  245. mock_pm.get_all_statuses.return_value = {}
  246. mock_ws.active_connections = []
  247. mock_db = AsyncMock()
  248. mock_result = MagicMock()
  249. mock_result.scalar.return_value = 0
  250. mock_result.scalar_one_or_none.return_value = None
  251. mock_result.scalars.return_value.all.return_value = []
  252. mock_db.execute = AsyncMock(return_value=mock_result)
  253. mock_session_ctx.return_value.__aenter__ = AsyncMock(return_value=mock_db)
  254. mock_session_ctx.return_value.__aexit__ = AsyncMock(return_value=False)
  255. info = await _collect_support_info()
  256. assert info["environment"]["timezone"] == "America/New_York"
  257. assert info["environment"]["docker"] is False
  258. @pytest.mark.asyncio
  259. @pytest.mark.unit
  260. async def test_docker_section_present_when_in_docker(self):
  261. """Verify docker section is added when running in Docker."""
  262. from backend.app.api.routes.support import _collect_support_info
  263. with (
  264. patch("backend.app.api.routes.support.is_running_in_docker", return_value=True),
  265. patch("backend.app.api.routes.support._get_container_memory_limit", return_value=1073741824),
  266. patch("backend.app.api.routes.support._detect_docker_network_mode", return_value="bridge"),
  267. patch("backend.app.api.routes.support.async_session") as mock_session_ctx,
  268. patch("backend.app.api.routes.support.printer_manager") as mock_pm,
  269. patch(
  270. "backend.app.api.routes.support.get_network_interfaces",
  271. return_value=[{"name": "eth0", "subnet": "172.17.0.0/16"}],
  272. ),
  273. patch("backend.app.api.routes.support.ws_manager") as mock_ws,
  274. ):
  275. mock_pm.get_all_statuses.return_value = {}
  276. mock_ws.active_connections = []
  277. mock_db = AsyncMock()
  278. mock_result = MagicMock()
  279. mock_result.scalar.return_value = 0
  280. mock_result.scalar_one_or_none.return_value = None
  281. mock_result.scalars.return_value.all.return_value = []
  282. mock_db.execute = AsyncMock(return_value=mock_result)
  283. mock_session_ctx.return_value.__aenter__ = AsyncMock(return_value=mock_db)
  284. mock_session_ctx.return_value.__aexit__ = AsyncMock(return_value=False)
  285. info = await _collect_support_info()
  286. assert "docker" in info
  287. assert info["docker"]["container_memory_limit_bytes"] == 1073741824
  288. assert info["docker"]["container_memory_limit_formatted"] == "1.00 GB"
  289. assert info["docker"]["network_mode_hint"] == "bridge"
  290. @pytest.mark.asyncio
  291. @pytest.mark.unit
  292. async def test_docker_section_absent_when_not_docker(self):
  293. """Verify docker section is absent when not in Docker."""
  294. from backend.app.api.routes.support import _collect_support_info
  295. with (
  296. patch("backend.app.api.routes.support.is_running_in_docker", return_value=False),
  297. patch("backend.app.api.routes.support.async_session") as mock_session_ctx,
  298. patch("backend.app.api.routes.support.printer_manager") as mock_pm,
  299. patch("backend.app.api.routes.support.get_network_interfaces", return_value=[]),
  300. patch("backend.app.api.routes.support.ws_manager") as mock_ws,
  301. ):
  302. mock_pm.get_all_statuses.return_value = {}
  303. mock_ws.active_connections = []
  304. mock_db = AsyncMock()
  305. mock_result = MagicMock()
  306. mock_result.scalar.return_value = 0
  307. mock_result.scalar_one_or_none.return_value = None
  308. mock_result.scalars.return_value.all.return_value = []
  309. mock_db.execute = AsyncMock(return_value=mock_result)
  310. mock_session_ctx.return_value.__aenter__ = AsyncMock(return_value=mock_db)
  311. mock_session_ctx.return_value.__aexit__ = AsyncMock(return_value=False)
  312. info = await _collect_support_info()
  313. assert "docker" not in info
  314. @pytest.mark.asyncio
  315. @pytest.mark.unit
  316. async def test_dependencies_section(self):
  317. """Verify dependencies section lists package versions."""
  318. from backend.app.api.routes.support import _collect_support_info
  319. with (
  320. patch("backend.app.api.routes.support.is_running_in_docker", return_value=False),
  321. patch("backend.app.api.routes.support.async_session") as mock_session_ctx,
  322. patch("backend.app.api.routes.support.printer_manager") as mock_pm,
  323. patch("backend.app.api.routes.support.get_network_interfaces", return_value=[]),
  324. patch("backend.app.api.routes.support.ws_manager") as mock_ws,
  325. ):
  326. mock_pm.get_all_statuses.return_value = {}
  327. mock_ws.active_connections = []
  328. mock_db = AsyncMock()
  329. mock_result = MagicMock()
  330. mock_result.scalar.return_value = 0
  331. mock_result.scalar_one_or_none.return_value = None
  332. mock_result.scalars.return_value.all.return_value = []
  333. mock_db.execute = AsyncMock(return_value=mock_result)
  334. mock_session_ctx.return_value.__aenter__ = AsyncMock(return_value=mock_db)
  335. mock_session_ctx.return_value.__aexit__ = AsyncMock(return_value=False)
  336. info = await _collect_support_info()
  337. assert "dependencies" in info
  338. # fastapi should be installed in test environment
  339. assert "fastapi" in info["dependencies"]
  340. assert info["dependencies"]["fastapi"] is not None
  341. @pytest.mark.asyncio
  342. @pytest.mark.unit
  343. async def test_websockets_section(self):
  344. """Verify websockets section shows connection count."""
  345. from backend.app.api.routes.support import _collect_support_info
  346. with (
  347. patch("backend.app.api.routes.support.is_running_in_docker", return_value=False),
  348. patch("backend.app.api.routes.support.async_session") as mock_session_ctx,
  349. patch("backend.app.api.routes.support.printer_manager") as mock_pm,
  350. patch("backend.app.api.routes.support.get_network_interfaces", return_value=[]),
  351. patch("backend.app.api.routes.support.ws_manager") as mock_ws,
  352. ):
  353. mock_pm.get_all_statuses.return_value = {}
  354. mock_ws.active_connections = ["conn1", "conn2"]
  355. mock_db = AsyncMock()
  356. mock_result = MagicMock()
  357. mock_result.scalar.return_value = 0
  358. mock_result.scalar_one_or_none.return_value = None
  359. mock_result.scalars.return_value.all.return_value = []
  360. mock_db.execute = AsyncMock(return_value=mock_result)
  361. mock_session_ctx.return_value.__aenter__ = AsyncMock(return_value=mock_db)
  362. mock_session_ctx.return_value.__aexit__ = AsyncMock(return_value=False)
  363. info = await _collect_support_info()
  364. assert info["websockets"]["active_connections"] == 2
  365. @pytest.mark.asyncio
  366. @pytest.mark.unit
  367. async def test_network_section(self):
  368. """Verify network section shows interface subnets."""
  369. from backend.app.api.routes.support import _collect_support_info
  370. mock_interfaces = [
  371. {"name": "eth0", "ip": "192.168.1.100", "netmask": "255.255.255.0", "subnet": "192.168.1.0/24"},
  372. {"name": "wlan0", "ip": "10.0.0.50", "netmask": "255.255.255.0", "subnet": "10.0.0.0/24"},
  373. ]
  374. with (
  375. patch("backend.app.api.routes.support.is_running_in_docker", return_value=False),
  376. patch("backend.app.api.routes.support.async_session") as mock_session_ctx,
  377. patch("backend.app.api.routes.support.printer_manager") as mock_pm,
  378. patch("backend.app.api.routes.support.get_network_interfaces", return_value=mock_interfaces),
  379. patch("backend.app.api.routes.support.ws_manager") as mock_ws,
  380. ):
  381. mock_pm.get_all_statuses.return_value = {}
  382. mock_ws.active_connections = []
  383. mock_db = AsyncMock()
  384. mock_result = MagicMock()
  385. mock_result.scalar.return_value = 0
  386. mock_result.scalar_one_or_none.return_value = None
  387. mock_result.scalars.return_value.all.return_value = []
  388. mock_db.execute = AsyncMock(return_value=mock_result)
  389. mock_session_ctx.return_value.__aenter__ = AsyncMock(return_value=mock_db)
  390. mock_session_ctx.return_value.__aexit__ = AsyncMock(return_value=False)
  391. info = await _collect_support_info()
  392. assert info["network"]["interface_count"] == 2
  393. assert info["network"]["interfaces"][0]["name"] == "eth0"
  394. assert info["network"]["interfaces"][0]["subnet"] == "x.x.1.0/24"
  395. # Verify IP addresses are NOT included (first two octets masked)
  396. for iface in info["network"]["interfaces"]:
  397. assert "ip" not in iface
  398. assert iface["subnet"].startswith("x.x.")
  399. @pytest.mark.asyncio
  400. @pytest.mark.unit
  401. async def test_log_file_section(self):
  402. """Verify log file section shows size info."""
  403. from backend.app.api.routes.support import _collect_support_info
  404. with tempfile.TemporaryDirectory() as tmpdir:
  405. log_dir = Path(tmpdir)
  406. log_file = log_dir / "bambuddy.log"
  407. log_file.write_text("some log content\n" * 100)
  408. with (
  409. patch("backend.app.api.routes.support.is_running_in_docker", return_value=False),
  410. patch("backend.app.api.routes.support.async_session") as mock_session_ctx,
  411. patch("backend.app.api.routes.support.printer_manager") as mock_pm,
  412. patch("backend.app.api.routes.support.get_network_interfaces", return_value=[]),
  413. patch("backend.app.api.routes.support.ws_manager") as mock_ws,
  414. patch("backend.app.api.routes.support.settings") as mock_settings,
  415. ):
  416. mock_settings.base_dir = Path(tmpdir)
  417. mock_settings.log_dir = log_dir
  418. mock_settings.debug = False
  419. mock_pm.get_all_statuses.return_value = {}
  420. mock_ws.active_connections = []
  421. mock_db = AsyncMock()
  422. mock_result = MagicMock()
  423. mock_result.scalar.return_value = 0
  424. mock_result.scalar_one_or_none.return_value = None
  425. mock_result.scalars.return_value.all.return_value = []
  426. mock_db.execute = AsyncMock(return_value=mock_result)
  427. mock_session_ctx.return_value.__aenter__ = AsyncMock(return_value=mock_db)
  428. mock_session_ctx.return_value.__aexit__ = AsyncMock(return_value=False)
  429. info = await _collect_support_info()
  430. assert "log_file" in info
  431. assert info["log_file"]["size_bytes"] > 0
  432. assert "B" in info["log_file"]["size_formatted"] or "KB" in info["log_file"]["size_formatted"]