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

Open
#481 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
elixir

Research direction

Start at lib/phoenix/live_dashboard/request_logger.ex around line 35 and inspect its call to Plug.Conn.fetch_query_params/2 alongside the linked Plug.Parsers behavior. Confirm that requests with non-UTF-8 query parameters and validate_utf8: false no longer raise through the request logger, and add or update relevant coverage if present.

Written by the indexing model from the issue text.

Description

Related: https://github.com/phoenixframework/phoenix_live_dashboard/issues/470, https://github.com/elixir-plug/plug/issues/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!

Dominant language
Elixir
Stars
2.2k
Forks
206
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from phoenixframework/phoenix_live_dashboard

All issues in phoenixframework/phoenix_live_dashboard

Similar issues

More Elixir issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.