Skip to content

Commit 1228857

Browse files
committed
fix: improve yaml load
As handling `active_backfill` seems to be entirely unsupported we are ignoring that field for now until we have a proper implementation
1 parent a8c62d6 commit 1228857

File tree

2 files changed

+76
-5
lines changed

2 files changed

+76
-5
lines changed

lib/sequin/transforms/transforms.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,7 @@ defmodule Sequin.Transforms do
432432
end
433433

434434
"encrypted_headers" ->
435-
case parse_headers(value) do
436-
{:ok, headers} -> {:cont, {:ok, Map.put(acc, :encrypted_headers, headers)}}
437-
{:error, error} -> {:halt, {:error, error}}
438-
end
435+
{:cont, {:ok, acc}}
439436

440437
"webhook.site" ->
441438
if value in [true, "true"] do
@@ -597,6 +594,9 @@ defmodule Sequin.Transforms do
597594
"max_retry_count" when is_integer(value) and value >= 0 ->
598595
{:cont, {:ok, Map.put(acc, :max_retry_count, value)}}
599596

597+
"max_retry_count" when is_nil(value) ->
598+
{:cont, {:ok, acc}}
599+
600600
"max_retry_count" ->
601601
{:halt, {:error, Error.validation(summary: "max_retry_count must be a non-negative integer")}}
602602

@@ -612,7 +612,7 @@ defmodule Sequin.Transforms do
612612
{:cont, {:ok, acc}}
613613

614614
# Ignore internal fields that might be present in the external data
615-
ignored when ignored in ~w(id inserted_at updated_at account_id replication_slot_id sequence_id) ->
615+
ignored when ignored in ~w(id inserted_at updated_at account_id replication_slot_id sequence_id active_backfill) ->
616616
{:cont, {:ok, acc}}
617617

618618
# Unknown field

test/sequin_web/controllers/yaml_controller_test.exs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,77 @@ defmodule SequinWeb.YamlControllerTest do
108108
"summary" => "Error creating database 'test-db': - database: can't be blank"
109109
}
110110
end
111+
112+
test "successfully plans configuration with wider set of fields", %{conn: conn} do
113+
yaml = """
114+
change_retentions:
115+
- name: test_retention
116+
filters: []
117+
destination_database: sequin_test
118+
source_database: sequin_test
119+
actions:
120+
- insert
121+
- update
122+
- delete
123+
source_table_name: accounts
124+
source_table_schema: public
125+
destination_table_name: sequin_events
126+
destination_table_schema: public
127+
databases:
128+
- name: sequin_test
129+
port: 5432
130+
ssl: false
131+
ipv6: false
132+
hostname: localhost
133+
pool_size: 10
134+
username: postgres
135+
password: '********'
136+
database: sequin_example
137+
slot_name: sequin_slot
138+
use_local_tunnel: false
139+
publication_name: sequin_pub
140+
http_endpoints:
141+
- name: test_http_endpoint
142+
url: http://localhost:4000/something
143+
headers: {}
144+
encrypted_headers: '(0 encrypted header(s)) - sha256sum: b4a8f200'
145+
sinks:
146+
- name: accounts_sink
147+
status: active
148+
table: public.accounts
149+
filters: []
150+
destination:
151+
port: 4222
152+
type: nats
153+
host: localhost
154+
tls: false
155+
database: sequin_test
156+
transform: record-transform
157+
active_backfill:
158+
batch_size: 1
159+
load_shedding_policy: pause_on_full
160+
max_retry_count:
161+
timestamp_format: iso8601
162+
actions:
163+
- insert
164+
- update
165+
- delete
166+
group_column_names:
167+
- user_id
168+
transforms:
169+
- name: record-transform
170+
type: path
171+
path: record
172+
description: Extracts just the record from the Sequin message shape.
173+
"""
174+
175+
conn = post(conn, ~p"/api/config/plan", %{yaml: yaml})
176+
177+
response = json_response(conn, 200)
178+
assert %{"changes" => changes} = response
179+
assert is_list(changes)
180+
end
181+
111182
end
112183

113184
describe "apply/2" do

0 commit comments

Comments
 (0)