Skip to content

Guard against nil publishes #166

Description

@mmmries

Our team at work had a case recently where we got an error log like this:

** (stop) exited in: GenServer.call(#PID<0.9002.25>, {:pub, nil, "+NXT", [reply_to: "_INBOX.AsRgaR8WHynMUJBk"]}, 5000)
    ** (EXIT) an exception was raised:
        ** (ArgumentError) errors were found at the given arguments:

  * 1st argument: not an iodata term

            :erlang.iolist_to_iovec([["PUB", " ", nil, " ", "_INBOX.AsRgaR8WHynMUJBk", " 4", "\r
", "+NXT", "\r
"]])
            (ssl 10.8.4) ssl.erl:856: :ssl.send/2
            (gnat 1.6.0) lib/gnat.ex:434: Gnat.handle_call/3
            (stdlib 4.1) gen_server.erl:1149: :gen_server.try_handle_call/4
            (stdlib 4.1) gen_server.erl:1178: :gen_server.handle_msg/6
            (stdlib 4.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
    (elixir 1.14.5) lib/gen_server.ex:1038: GenServer.call/3
    (gnat 1.6.0) lib/gnat.ex:211: Gnat.pub/4
    (jetstream 0.0.8) lib/jetstream/pull_consumer/server.ex:195: Jetstream.PullConsumer.Server.handle_info/2
    (connection 1.1.0) lib/connection.ex:810: Connection.handle_async/3
    (stdlib 4.1) gen_server.erl:1123: :gen_server.try_dispatch/4
    (stdlib 4.1) gen_server.erl:1200: :gen_server.handle_msg/6

This looks like a case where we are passing a nil value into one of the pubic Gnat functions and it is getting passed along in a message to the connection process where it crashes because it isn't a valid iolist. This seems like something that should return an error or raise an ArgumentError if a nil is passed into the function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions