cambiatus / backend

Cambiatus GraphQL API
GNU Affero General Public License v3.0
20 stars 18 forks source link

Error when getting rich link language #298

Open sentry-io[bot] opened 2 years ago

sentry-io[bot] commented 2 years ago

We had an error when setting the rich link language. This happened because we try to get the accept-langauge http header and determine the language in which the rich link should be rendered. But we don't properly format this header.

We should either not get the header from the http request (since this is the only place in the app where we try to get this header) or implement it following all its specifications.


Sentry Issue: BACKEND-8F

ArgumentError: argument error
  Module "erlang", in :erlang.binary_to_existing_atom/2
  File "lib/cambiatus_web/controllers/rich_link_controller.ex", line 127, in CambiatusWeb.RichLinkController.get_language/2
  File "lib/cambiatus_web/controllers/rich_link_controller.ex", line 65, in CambiatusWeb.RichLinkController.product_rich_link/3
    case Accounts.get_user(nil, %{account: account}, nil) do
  File "lib/cambiatus_web/controllers/rich_link_controller.ex", line 25, in CambiatusWeb.RichLinkController.rich_link/2
    user_rich_link(account, community_subdomain, language)
  File "lib/cambiatus_web/controllers/rich_link_controller.ex", line 1, in CambiatusWeb.RichLinkController.action/2
    defmodule CambiatusWeb.RichLinkController do
...
(3 additional frame(s) were not displayed)

(ArgumentError argument error)