Hit a tricky debugging scenario today that cost me more time than I’d like to admit.

I accidentally changed a function’s return value from {:ok, atom} to just atom. Elsewhere in the code, I was calling that function with:

with {:ok, atom} <- function() do
  # ...
end

After the change, this stopped working because there was no :ok tuple to match against. The confusing part? The error that showed up in the logs was a “missing case clause error” rather than something more obvious like a pattern match failure.

What made this extra painful to track down was that the code was running inside a GenServer, so everything was happening asynchronously. The error didn’t bubble up in an obvious way, and the stack trace wasn’t immediately helpful.

Lesson learned: when you see case clause errors in Elixir, especially in async contexts like GenServers, double-check that your function return values haven’t changed and that your pattern matches are still valid.