From 263c1bbdf5bbe51bde29a31cd325f2e3cb0c727e Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sun, 12 Apr 2026 17:50:04 -0500 Subject: [PATCH] Fix /path crash on clear-terrain diffraction loss TerrainAnalysis.deygout_diffraction/2 short-circuits to integer 0 when the path has no interior points or the principal edge nu is below the shadow boundary, which then made Float.round/2 blow up inside compute_loss_budget when the rest of the losses were all floats. Multiply the diffraction value by 1.0 before it feeds into the total so clear paths coerce cleanly without touching TerrainAnalysis's (number()) contract. --- lib/microwaveprop_web/live/path_live.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/microwaveprop_web/live/path_live.ex b/lib/microwaveprop_web/live/path_live.ex index 4592b099..4161bfce 100644 --- a/lib/microwaveprop_web/live/path_live.ex +++ b/lib/microwaveprop_web/live/path_live.ex @@ -380,7 +380,9 @@ defmodule MicrowavepropWeb.PathLive do diffraction_loss = if terrain_result do - terrain_result.analysis.diffraction_db + # TerrainAnalysis.deygout_diffraction returns integer 0 for clear + # paths; coerce to float so Float.round/2 below is happy. + terrain_result.analysis.diffraction_db * 1.0 else 0.0 end