Drone: Write error message to hook response

Created on 23 Apr 2015  路  6Comments  路  Source: drone/drone

There are a lot of w.WriteHeader(http.StatusBadRequest) with response body in https://github.com/drone/drone/blob/master/server/handler/hook.go so when trying to debug a 400, it makes it quite difficult.

Edit: Sorry for the half post. Just learnt that Ctrl+Enter in Github issues, submits the form, where in other services it adds a new-line (explicitly not submitting)

Also, note, I can send a PR, though I wanted to check first incase this was done on purpose for security reasons.

Most helpful comment

HTTP/1.1 400 (Bad Request)
Some: Headers

<Message goes here>

If .drone.yml isn't found, it sends the above response with no message, or maybe I missing something...

No need to check spelling. Instead of doing many:

w.WriteHeader(http.StatusBadRequest)
return

Do

w.WriteHeader(http.StatusBadRequest)
w.Write([]byte(err.Error())) //assuming err contains the error
return

This would allow for webhook debugging in Github like:

screen shot 2015-04-24 at 12 26 39 am

Happy to send a PR, though wasn't sure if this was on purpose or maybe you guys were handling errors elsewhere

All 6 comments

For example, it took me quite some time to figure out that my .drone.yaml should have been .drone.yml.

How would such a message look?
If .drone.yml doesnt exist it will tell you that it can't find it.
I don't think we should check missspellings.

HTTP/1.1 400 (Bad Request)
Some: Headers

<Message goes here>

If .drone.yml isn't found, it sends the above response with no message, or maybe I missing something...

No need to check spelling. Instead of doing many:

w.WriteHeader(http.StatusBadRequest)
return

Do

w.WriteHeader(http.StatusBadRequest)
w.Write([]byte(err.Error())) //assuming err contains the error
return

This would allow for webhook debugging in Github like:

screen shot 2015-04-24 at 12 26 39 am

Happy to send a PR, though wasn't sure if this was on purpose or maybe you guys were handling errors elsewhere

this is something we've been working on. This branch has logging and returns errors for the hook:
https://github.com/drone/drone/blob/bolt/server/hooks.go

logging is the most "cross platform" solution since not every provider (ie Bitbucket, etc) has nice administrative screens to inspect webhook logs. But we do write error messages to the output which should be helpful for GitHub users.

@bradrydzewski awesome, looks good! I'm using Gitlab, indeed it lacks a nice admin screen for webhooks, so I just replicated the webhook in curl and this bolt branch will help.

writing error to hooks merged into master, so this can be closed now

Was this page helpful?
0 / 5 - 0 ratings