Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions .changeset/eleven-boats-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@core/sync-service': patch
---

fix: mark one more service-specific error as known
18 changes: 18 additions & 0 deletions packages/sync-service/lib/electric/db_connection_error.ex
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,24 @@ defmodule Electric.DbConnectionError do
}
end

def from_error(
%Postgrex.Error{
postgres: %{
code: :invalid_authorization_specification,
message: "branch " <> _,
severity: "FATAL",
pg_code: "28000"
}
} = error
) do
%DbConnectionError{
message: error.postgres.message,
type: :branch_does_not_exist,
original_error: error,
retry_may_fix?: false
}
end

def from_error(%Postgrex.Error{postgres: %{code: :admin_shutdown, severity: "FATAL"}} = error) do
%DbConnectionError{
message: error.postgres.message,
Expand Down
22 changes: 22 additions & 0 deletions packages/sync-service/test/electric/db_connection_error_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,28 @@ defmodule Electric.DbConnectionErrorTest do
} == DbConnectionError.from_error(error)
end

test "with branch does not exist error" do
error = %Postgrex.Error{
message: nil,
postgres: %{
code: :invalid_authorization_specification,
message: "branch 3ibd4pbmos9p does not exist",
unknown: "FATAL",
severity: "FATAL",
pg_code: "28000"
},
connection_id: nil,
query: nil
}

assert %DbConnectionError{
message: "branch 3ibd4pbmos9p does not exist",
type: :branch_does_not_exist,
original_error: error,
retry_may_fix?: false
} == DbConnectionError.from_error(error)
end

test "with an unknown error" do
error = %DBConnection.ConnectionError{
message: "made-up error",
Expand Down