Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(KeyError) key :peer not found in: %Plug.Conn{adapter: {Plug.Adapters.Cowboy.Conn, :...} #275

Closed
samsondav opened this issue Jun 19, 2018 · 9 comments
Assignees

Comments

@samsondav
Copy link

samsondav commented Jun 19, 2018

Environment

  • Elixir version (elixir -v): Elixir 1.6.5 (compiled with OTP 19)
  • Erlang/OTP version (erl): Erlang/OTP 20
  • Sentry version (mix deps): sentry "6.2.1"
  • Operating system: Linux

Description

We recently upgrade to plug 1.6. Now if we get an exception, we see the following error:

* (exit) an exception was raised:
    ** (KeyError) key :peer not found in: %Plug.Conn{adapter: {Plug.Adapters.Cowboy.Conn, :...}, assigns: %{spandex_trace_request?: true}, before_send: [#Function<0.46709343/1 in Eggl.Monitoring.trace/1>], body_params: %{"operationName" => "Buyer", "query" => "query Buyer($id: ID) {\n  buyer(id: $id) {\n    ...buyerFields\n    __typename\n  }\n}\n\nfragment buyerFields on Buyer {\n  id\n  name\n  address\n  email\n  telephone\n  closeIoLeadId\n  leadStatus\n  __typename\n}\n", "variables" => %{"id" => "1"}}, cookies: %{}, halted: false, host: "localhost", method: "POST", owner: #PID<0.1263.0>, params: %{"operationName" => "Buyer", "query" => "query Buyer($id: ID) {\n  buyer(id: $id) {\n    ...buyerFields\n    __typename\n  }\n}\n\nfragment buyerFields on Buyer {\n  id\n  name\n  address\n  email\n  telephone\n  closeIoLeadId\n  leadStatus\n  __typename\n}\n", "variables" => %{"id" => "1"}}, path_info: ["graphql"], path_params: %{}, port: 5021, private: %{Eggl.Router => {[], %{Absinthe.Plug.GraphiQL => ["graphiql"], Eggl.Router.PrivateGraphql => [], Eggl.Router.PublicGraphql => []}}, :phoenix_endpoint => Eggl.Endpoint, :phoenix_pipelines => [:graphql], :phoenix_router => Eggl.Router}, query_params: %{}, query_string: "", remote_ip: {127, 0, 0, 1}, req_cookies: %{}, req_headers: [{"host", "localhost:5021"}, {"proxy-connection", "keep-alive"}, {"content-length", "277"}, {"accept", "*/*"}, {"x-client-id", "bc3b017a-3feb-421e-82f9-8005a6d14520"}, {"user-agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Cypress/3.0.1 Chrome/59.0.3071.115 Electron/1.8.2 Safari/537.36"}, {"authorization", "Bearer eyJhbGciOiJSUzUxMiJ9.eyJpZCI6MX0.F3VXMze8kMYcOQ73qMYXsu0533_0WpgWFwFBHjQleymgIondWEHniJxeCkgyGGpSdKRDg66wZDz4sPBnRPHFaLazRxSFCg7B7dBhkQDY-mfKhoHiVJntbbH__tPkHsHpkjylcdX5d0bH1MHJChuLLRwmOBch01ipkdcEvaGtZKqJXg6TcDF4VYwQFdD8GTXdY2OiVatTB9T3swuD_RzHkxl_lYRWqo7RqkmnIkewjOHozOmd-WLSBlil6GgHDnBiRjxVJ5Eg6VzfMHBxhHyzIm0SgpIAUYL90Yt7rH8PzHXI6doHym8FfT3k-feSnLc2qokPYURzqMPrJWZQBV1g3Q"}, {"origin", "http://localhost:8090"}, {"content-type", "application/json"}, {"referer", "http://localhost:8090/buyers/1"}, {"accept-encoding", "gzip"}, {"accept-language", "en-US"}, {"connection", "close"}], request_path: "/graphql", resp_body: nil, resp_cookies: %{}, resp_headers: [{"cache-control", "max-age=0, private, must-revalidate"}, {"x-request-id", "2ksp6vhipsig5qibp8000082"}, {"access-control-allow-origin", "*"}, {"access-control-expose-headers", ""}, {"access-control-allow-credentials", "true"}], scheme: :http, script_name: [], secret_key_base: "YkigGLAM+4AitkN3A4zmAkAl9SjxkJmf9JxBuTb07yvGJPqLVc9JQ4YCn+8gCIEf", state: :unset, status: 500}
        (sentry) lib/sentry/plug.ex:174: Sentry.Plug.build_request_interface_data/2
        (eggl) lib/eggl/router.ex:5: Eggl.Router.handle_errors/2
        (plug) lib/plug/error_handler.ex:91: Plug.ErrorHandler.__catch__/6
        (eggl) lib/eggl/endpoint.ex:1: Eggl.Endpoint.plug_builder_call/2
        (eggl) lib/plug/debugger.ex:102: Eggl.Endpoint."call (overridable 3)"/2
        (eggl) lib/eggl/endpoint.ex:1: Eggl.Endpoint.call/2
        (plug) lib/plug/adapters/cowboy/handler.ex:16: Plug.Adapters.Cowboy.Handler.upgrade/4
        (cowboy) /app/deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4
@maartenvanvliet
Copy link

Is already a PR for: #273

@mitchellhenke
Copy link
Contributor

Yep, this was something of a regression in Plug 1.6.0 in that it removed :peer from Plug.Conn (and will be deprecated when it comes back).

@samphilipd should I make a release that supports 1.6.0, or will using another version be sufficient for you for now?

@dsnipe
Copy link

dsnipe commented Jun 20, 2018

Having the same.
Fortunately found it on staging. Probably will lock Plug for now.
@mitchellhenke when do you plan to do a new release with a fix for 1.6.0 version?

@samsondav
Copy link
Author

@mitchellhenke we downgraded to 1.5.1, which is fine for now. If 1.6.1 re-introduces the :peer key we can just wait for that version.

@mitchellhenke
Copy link
Contributor

mitchellhenke commented Jun 21, 2018

@dsnipe I was hoping 1.6.0 would be yanked and 1.6.1 would be released shortly so everything could continue functioning. I can release a new version of Sentry with #273 today if that's easiest for you.

@mitchellhenke mitchellhenke self-assigned this Jun 21, 2018
@dsnipe
Copy link

dsnipe commented Jun 21, 2018

I'm ok to wait, no rush.
But as far as I understand peer key will be deprecated, so anyway it will be removed somewhere in next versions.

lee-dohm added a commit to lee-dohm/atom-style-tweaks that referenced this issue Jun 22, 2018
@mattlorey
Copy link

Hey @mitchellhenke, seems this is stalled on both ends. Since even if :peer would be coming back it would be deprecated, could you release a new version with #273? Seems like that would be the long term solution

@mitchellhenke
Copy link
Contributor

@mattlorey yep, I'll do that right now

@mitchellhenke
Copy link
Contributor

I've merged #273 and released it as part of version 6.3.0 🙂

backspace added a commit to backspace/prison-rideshare-api that referenced this issue Dec 9, 2018
There’s a feature in JaSerializer 0.13 to apply this globally
but when I tried to use it I was pulled into a cascading
problem with these issues:
phoenixframework/phoenix#3119
getsentry/sentry-elixir#275

I couldn’t figure that out so I’m manually overriding instead
for now.

This is all happening because Mirage uses plural types and
the overlaps-processing client-side code needed to check
for both, ugh.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants