Skip to content

Mint.HTTP1.Request private fn validate_header_value throws Erlang error: {:bad_generator, nil} when value is nil #393

@marinac-dev

Description

@marinac-dev

If the value of header is nil it will just throw error.

** (ErlangError) Erlang error: {:bad_generator, nil}
    (mint 1.5.1) lib/mint/http1/request.ex:85: Mint.HTTP1.Request."-validate_header_value!/2-lc$^0/1-0-"/3
    (mint 1.5.1) lib/mint/http1/request.ex:85: Mint.HTTP1.Request.validate_header_value!/2
    (mint 1.5.1) lib/mint/http1/request.ex:27: anonymous fn/2 in Mint.HTT
    # . . . Stack strace

I think I could make a bug reproducing repo in free time, but what caused this in my case is a dependency.
In dependency, there is macro @api_key Application.compile_env(:my_app, :api_key) (yes I know I shouldn't use that, I will change it) which requires setting it in somewhere in config.exs but if I don't do that header value becomes nil and bum bug. :)

In my config, I use System.get_env to fetch header value
I am using Tesla with Finch adapter

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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