From 3ce1d5320762fea885d3fc9396d928d599a621ce Mon Sep 17 00:00:00 2001 From: Farhan Yahaya Date: Thu, 17 Sep 2026 12:38:10 +0000 Subject: [PATCH] validate run error_type against known worker error types --- lib/lightning/runs/handlers.ex | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/lightning/runs/handlers.ex b/lib/lightning/runs/handlers.ex index 96cf9ce14f..aa9128dc92 100644 --- a/lib/lightning/runs/handlers.ex +++ b/lib/lightning/runs/handlers.ex @@ -115,6 +115,12 @@ defmodule Lightning.Runs.Handlers do end end + # Error types a worker can report on a finished run. + @known_error_types ~w( + UserError RuntimeError RuntimeCrash CompileError AdaptorError + TimeoutError OOMError Lost LostAfterStart + ) + def new(params) do %__MODULE__{} |> cast(params, [ @@ -125,6 +131,7 @@ defmodule Lightning.Runs.Handlers do :final_state, :timestamp ]) + |> validate_inclusion(:error_type, @known_error_types) |> put_new_change(:timestamp, Lightning.current_time()) |> then(fn changeset -> if reason = get_change(changeset, :reason) do