Skip to content

Phoenix.LiveDashboard.RequestLogger does not respect Plug.Parsers validate_utf8: false #481

@ckampfe

Description

@ckampfe

Related: #470, elixir-plug/plug#925

I apologize for the title, I'm not sure exactly what this should be called.

I have an endpoint that needs to receive non-UTF-8 query params. Thankfully, there is the validate_utf8: false option that I can set on Plug.Parsers, so thank you for that.

However, I get errors like [debug] ** (Plug.Conn.InvalidQueryError) invalid UTF-8 on urlencoded params, got byte 159 when the Phoenix.LiveDashboard.RequestLogger plug is enabled, even when Plug.Parsers validate_utf8 is set to false.

When enabled in Phoenix's endpoint.ex (which it is by default), the Phoenix.LiveDashboard.RequestLogger plug appears to call Plug.Conn.fetch_query_params/2 with the default options here, which have validate_utf8 set to true.

I can confirm that commenting out the Phoenix.LiveDashboard.RequestLogger plug causes the plug stack to no longer raise, so this is not a big deal, but I'm just reporting this because this may be slightly confusing to others who set Plug.Parsers validate_utf8: false and then continue to see the exception. I know this confused me: I set validate_utf8: false and my endpoint continued to crash for requests that had non-UTF-8 data, until I dug into the stack trace and saw that it wasn't coming from Plug.Parsers but was coming from Phoenix.LiveDashboard.RequestLogger.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions