No match of right hand side value when using the sandbox endpoint
jerel opened this issue · 6 comments
I'm giving the sandbox plug a try and I get this error when doing a POST
to /sandbox
:
[error] #PID<0.1526.0> running Web.Endpoint terminated
Server: localhost:4000 (http)
Request: POST /sandbox
** (exit) an exception was raised:
** (MatchError) no match of right hand side value: {:error, {{:case_clause, {:error, :invalid_message}}, [{DBConnection.Ownership, :ownership_checkout, 2, [file: 'lib/db_connection/ownership.ex', line: 58]}, {Ecto.Adapters.SQL.Sandbox, :checkout, 2, [file: 'lib/ecto/adapters/sql/sandbox.ex', line: 477]}, {Phoenix.Ecto.SQL.SandboxSession, :init, 1, [file: 'lib/phoenix_ecto/sql/sandbox_session.ex', line: 15]}, {:gen_server, :init_it, 2, [file: 'gen_server.erl', line: 365]}, {:gen_server, :init_it, 6, [file: 'gen_server.erl', line: 333]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 247]}]}}
(phoenix_ecto) lib/phoenix_ecto/sql/sandbox.ex:100: Phoenix.Ecto.SQL.Sandbox.call/2
(web) lib/web/endpoint.ex:1: Web.Endpoint.plug_builder_call/2
(web) lib/web/endpoint.ex:45: Web.Endpoint."call (overridable 2)"/2
(web) lib/plug/debugger.ex:99: Web.Endpoint."call (overridable 3)"/2
(web) lib/web/endpoint.ex:1: Web.Endpoint.call/2
I've configured it by adding this to the endpoint before the router:
plug Phoenix.Ecto.SQL.Sandbox,
at: "/sandbox",
header: "x-user-agent",
repo: App.Repo
I'm running ecto
2.2.8 and phoenix_ecto
3.3. Does this error look familiar to anyone?
Weird. I haven't seen anything like this and it looks like it's coming from within Ecto's call do DBConnection. Can you verify your db_connection
version and maybe make sure you're pin the latest stable? Thanks!
db_connection
is pinned to 1.1.3. After some more experimenting it turned out that hitting the endpoint while running with MIX_ENV=dev
instead of test
is what was causing this error.
I will fix this in Ecto if possible, thanks for the report!
This is still happening for me on Elixir 1.7.1 with phoenix_ecto 3.3.0 and ecto 2.2.10. db_connection is 1.1.3 as well.
After some more experimenting it turned out that hitting the endpoint while running with MIX_ENV=dev instead of test is what was causing this error.
I am not quite sure what you mean by this, @jerel. I tried running the phoenix server with MIX_ENV=test mix phx.server
, but this does not even start.
@phikes his comment was because he was starting the dev in server (which does not use the sandbox) and then trying to use the sandbox. You need to make sure that you run the server in test and the sandbox is enabled in your config files. If you you can't invoke MIX_ENV=test mix phx.server
, that should be your starting point, as both this command and mix test
should work.
Ah ok, I wasn't aware of that. Thanks for the swift reply. Please let me know if I can help in any way ;-). I will look into the server not starting in the test environment.