Fix pipeline validation not working
This commit is contained in:
parent
09d2e4ae72
commit
c37bed932f
|
@ -18,11 +18,10 @@ defmodule Frenzy.Pipeline.ScrapeStage do
|
||||||
|
|
||||||
@impl Stage
|
@impl Stage
|
||||||
def validate_opts(opts) when is_map(opts) do
|
def validate_opts(opts) when is_map(opts) do
|
||||||
# todo: figure out why this errors when an empty map is provided
|
|
||||||
opts =
|
opts =
|
||||||
case opts["extractor"] do
|
case opts["extractor"] do
|
||||||
nil ->
|
nil ->
|
||||||
{:ok, %{opts | extractor: "builtin"}}
|
{:ok, Map.put(opts, "extractor", "builtin")}
|
||||||
|
|
||||||
extractor when not is_binary(extractor) ->
|
extractor when not is_binary(extractor) ->
|
||||||
{:error, "extractor must be a string"}
|
{:error, "extractor must be a string"}
|
||||||
|
@ -44,7 +43,7 @@ defmodule Frenzy.Pipeline.ScrapeStage do
|
||||||
{:ok, opts} ->
|
{:ok, opts} ->
|
||||||
case opts["convert_to_data_uris"] do
|
case opts["convert_to_data_uris"] do
|
||||||
nil ->
|
nil ->
|
||||||
{:ok, %{opts | convert_to_data_uris: true}}
|
{:ok, Map.put(opts, "convert_to_data_uris", true)}
|
||||||
|
|
||||||
value when is_boolean(value) ->
|
value when is_boolean(value) ->
|
||||||
{:ok, opts}
|
{:ok, opts}
|
||||||
|
|
|
@ -105,7 +105,7 @@ defmodule FrenzyWeb.PipelineController do
|
||||||
else
|
else
|
||||||
{:error, reason} ->
|
{:error, reason} ->
|
||||||
conn
|
conn
|
||||||
|> put_flash(:error, "Unable to edit pipeline: #{inspect(reason)}")
|
|> put_flash(:error, "Unable to edit pipeline: #{reason}")
|
||||||
|> render("edit.html", %{
|
|> render("edit.html", %{
|
||||||
pipeline: pipeline,
|
pipeline: pipeline,
|
||||||
name: name,
|
name: name,
|
||||||
|
@ -123,7 +123,7 @@ defmodule FrenzyWeb.PipelineController do
|
||||||
{:cont, {:ok, new_stages ++ [stage]}}
|
{:cont, {:ok, new_stages ++ [stage]}}
|
||||||
|
|
||||||
{:error, reason} ->
|
{:error, reason} ->
|
||||||
{:error, "invalid stage at #{index}: #{reason}"}
|
{:halt, {:error, "invalid stage at index #{index}: #{reason}"}}
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue