OpenFn / OpenFn/lightning

Ensure we send 406 errors for unsupported accept types

Open
#2,046 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Elixir
Stars
296
Forks
86
Avg merge
1d 13h
Merged PRs (30d)
50

Description

Looks like we have bots etc poking around for things, not sure why this got logged into sentry.

For this class of situation we should gracefully return a 406.

Sentry Issue: LIGHTNING-AK

Phoenix.NotAcceptableError: no supported media type in accept header.

Expected one of ["html"] but got the following formats:

  * "application/dns-json" with extensions: []

To accept custom formats, register them under the :mime library
in your config/config.exs file:

    config :mime, :types, %{
      "application/xml" => ["xml"]
    }

And then run `mix deps.clean --build mime` to force it to be recompiled.

  File "lib/phoenix/controller.ex", line 1606, in Phoenix.Controller.refuse/3
  Module "Elixir.LightningWeb.Router", in LightningWeb.Router.browser/2
  File "lib/lightning_web/router.ex", line 1, in LightningWeb.Router.__pipe_through3__/1
  File "lib/phoenix/router.ex", line 475, in Phoenix.Router.__call__/5
  File "lib/lightning_web/endpoint.ex", line 1, in LightningWeb.Endpoint.plug_builder_call/2
...
(3 additional frame(s) were not displayed)

(Phoenix.NotAcceptableError no supported media type in accept header.

Expected one of ["html"] but got the following formats:

  * "application/dns-json" with extensions: []

To accept custom formats, register them under the :mime library
in your config/config.exs file:

    config :mime, :types, %{
      "application/xml" => ["xml"]
    }

And then run `mix deps.clean --build mime` to force it to be recompiled.
)

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Start with the browser pipeline in lib/lightning_web/router.ex and follow the request path through lib/lightning_web/endpoint.ex, using the reported Phoenix.NotAcceptableError as the reproduction. Confirm that an unsupported Accept header receives HTTP 406 rather than surfacing the exception, and add or update the relevant request coverage if the repository provides it.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.