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

Different payloads received for dev and prod environment? #19

Closed
SimonLab opened this issue Mar 10, 2017 · 5 comments
Closed

Different payloads received for dev and prod environment? #19

SimonLab opened this issue Mar 10, 2017 · 5 comments

Comments

@SimonLab
Copy link
Member

Some context: Each time an event appears on Github (new label, new issue,...) my server receive a POST request from Github with all the information of the event store in the payload (body) of the request. The format of the paylod seems however different on my loacalhost and on Heroku:

On Heroku the payload received is already parse to Json:

Parameters: %{"action" => "unlabeled", "issue" => %{"assignee" => nil,...

On localhost the payload as the following format:

{ payload: '{"action":"unlabeled","issue":...

The the first one is a json object, the second one is also a json object but with just one property "payload" which has for value the stringify response.
Which means that on localhost I need to use Poinon.decode to parse the value but this will break on production has the value is already parsed.

I've also deploy an hapi server on Heroku to see the format of the payload and it match the second version;

{ payload: '{"action":"unlabeled","issue":...

I'm not entirely sure why this difference exists and where it comes form, is it the way Github send the payload? Is it an option on Phoenix to parse automatically the payload on production but not on developement? Does anyone has any suggestion to help me understand how Phoenix manage the payload of a post request and why there is this difference in the format of the payload?

@nelsonic
Copy link
Member

@SimonLab which version of Elixir are you running on your Localhost vs. Heroku?

@SimonLab
Copy link
Member Author

@nelsonic

Localhost: Elixir 1.3.4

from elixir_buildpack:

erlang_version=18.3
elixir_version=1.3.4
always_rebuild=false
runtime_path=/app

The phoenix version is defined on the mix.exs and is phoenix, "~> 1.2.1" so it should be the same on localhost and Heroku

@SimonLab
Copy link
Member Author

Not a blocker anymore as I'm creating a switch to parse the payload properly depending on its format. But I still would like to understand the source of the problem 😟

@SimonLab
Copy link
Member Author

Ok, just being silly!!
content-type

When you create a webhooks check that select the right content type!! "application/json" and not "application/x-www-form-urlencoded"

I will remember this one now!

@nelsonic
Copy link
Member

@SimonLab this should be included in the readme/instructions for setting up web hooks...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants