fix(pubsub): pass VALKEY_URL as bare string to redis_opts, not [url: ...]

phoenix_pubsub_redis 3.1's deprecation message ('Move :url inside the
:redis_opts option') is misleading — wrapping the URL as
`redis_opts: [url: url]` forwards the keyword list to Redix, which
rejects `:url` with `unknown options [:url], valid options are:
[:host, :port, :password, ...]`. New pods on commit b4d6b04 onward
crashed at startup with that NimbleOptions.ValidationError; old pods
running e53a34d (top-level :url) coasted on already-established
connections so the breakage only surfaced when fresh pods rolled.

The library accepts `redis_opts` as either a URL binary OR a
keyword list. Pass the URL as a bare string so it takes the
binary-clause path that hands it directly to Redix.PubSub.start_link/1.
This commit is contained in:
Graham McIntire 2026-05-04 08:29:30 -05:00
parent 068629ee35
commit 067ed37a90
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -127,8 +127,14 @@ defmodule Microwaveprop.Application do
# Erlang's node() name in non-K8s environments.
node_name = System.get_env("POD_IP") || to_string(node())
{Phoenix.PubSub,
name: Microwaveprop.PubSub, adapter: Phoenix.PubSub.Redis, redis_opts: [url: url], node_name: node_name}
# phoenix_pubsub_redis 3.x: `redis_opts` accepts either a URL
# binary OR a keyword list of host/port/password/etc. The
# 3.1's deprecation warning ("Move :url inside the :redis_opts
# option instead") is misleading — `[url: url]` gets forwarded
# to Redix which rejects it as an unknown option (the valid
# keys are :host, :port, :password, …, NOT :url). The bare URL
# form takes the binary-clause and works correctly.
{Phoenix.PubSub, name: Microwaveprop.PubSub, adapter: Phoenix.PubSub.Redis, redis_opts: url, node_name: node_name}
end
end