-
Notifications
You must be signed in to change notification settings - Fork 9
update failed pr message #76
Conversation
2ed8d67
to
8b644ab
Compare
@codeclimate/review I thought this PR was ready re-review - but now am not sure why Travis Build is failing (exploring). Tests pass locally when I run It updates Goal is to provide clearer feedback to users when PR fails due to incompatible worker versions. First draft message in that case: See related changes in |
@@ -87,8 +86,7 @@ def presenter | |||
def update_status_error | |||
update_status( | |||
"error", | |||
"Code Climate encountered an error while attempting to analyze this " + | |||
"pull request." | |||
message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about @payload["message"] || DEFAULT_ERROR_MESSAGE
?
I think generally, all the update_status_x
methods should use @payload["message"] || SOME_DEFAULT
and let the callers be in charge of it (not the presenter here), but that's a bigger change and we can punt on it for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pbrisbin okay that's fine by me. I see some reasons supporting both places as the site of setting a message_default
- maybe it makes sense to have messages get set in one place, so finalizer
should worry about the messages and services
can just eat them. But on the other hand, I think having a default message on services
side is fine.
Generally, agree that it seems a little confusing that the presenter is used for some messages and not others (and the method is named success_message
even when the status is failure :p ). But punting sounds ideal to me. :) Keep changes separate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. cc-services should not be in the business of crafting messages based on data, etc. But having a sane, generic default seems totally reasonable. And is important for something like this which is a shared, open source gem that has to think about backwards compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmmm makes sense.
Imagine we'll probably also want to avoid fetching the message
then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, my example snippet should work and make the new #message
method unused (or keep it but use Hash#[]
instead).
@codeclimate/review I added the changes discussed above, including adding a New change that might need improvement: my naive attempt to remove the |
👍 LGTM |
update failed pr message
@@ -104,6 +107,9 @@ def update_status(state, description) | |||
target_url: @payload["details_url"], | |||
context: "codeclimate" | |||
} | |||
if state == "error" | |||
params.delete(:target_url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first glance, I don't love this. Why not just not include the target_url in the original payload. I don't think this class should be responsible for "overriding" the payload in this way. /c @gordondiggs @abaldwinhubter @pbrisbin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo. /cc @ABaldwinHunter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brynary apologies, just saw your note! I believe the thought was that removing the details_url
would remove the details
link from PRs that error out.
What's constructed in this update_status
method doesn't match the original payload perfectly, and without adding in a conditional, it might set the target_url
to nil
when @payload["details_url"]
gets left out.
That said, I think this is the place in finalizer
where payload
gets created and sent:
module Finalizer
class UpdatePullRequest
def initialize(ref_point)
@ref_point = ref_point
@repo = ref_point.repo
@pull_request = ref_point.pull_request
end
def update
return unless updatable?
emitter = EventEmitter.new
emitter.emit(
"pull_request",
state: evaluation.state,
issue_comparison_counts: {
new: evaluation.new_issue_count,
fixed: evaluation.fixed_issue_count,
},
details_url: evaluation.url,
compare_url: evaluation.url,
commit_sha: ref_point.commit_sha,
github_slug: repo.github_slug,
repo_id: repo.id.to_s,
number: pull_request.number,
message: evaluation.message,
)
end
We could perhaps make a change there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the goal of removing the link in errored PRs makes sense (temporarily). I was only commenting on the implementation.
It seems like we could either change the payload that is sent to not include the URL (which would require a change elsewhere) or remove it here. What are your thoughts on how it should work?
—Bryan Helmkamp, Founder, Code Climate
bryan@brynary.com / 646-379-1810 / @brynary
Typed with thumbs.
On Mon, Jul 6, 2015 at 4:44 PM, Ashley Baldwin-Hunter
notifications@github.com wrote:
@@ -104,6 +107,9 @@ def update_status(state, description)
target_url: @payload["details_url"],
context: "codeclimate"
}
if state == "error"
@brynary apologies, just saw your note! I believe the thought was that removing theparams.delete(:target_url)
details_url
would remove thedetails
link from PRs that error out.
What's constructed in thisupdate_status
method doesn't match the original payload perfectly, and without adding in a conditional, it might set thetarget_url
tonil
when@payload["details_url"]
gets left out.
That said, I think this is the place infinalizer
wherepayload
gets created and sent:module Finalizer class UpdatePullRequest def initialize(ref_point) @ref_point = ref_point @repo = ref_point.repo @pull_request = ref_point.pull_request end def update return unless updatable? emitter = EventEmitter.new emitter.emit( "pull_request", state: evaluation.state, issue_comparison_counts: { new: evaluation.new_issue_count, fixed: evaluation.fixed_issue_count, }, details_url: evaluation.url, compare_url: evaluation.url, commit_sha: ref_point.commit_sha, github_slug: repo.github_slug, repo_id: repo.id.to_s, number: pull_request.number, message: evaluation.message, ) endWe could perhaps make a change there.
Reply to this email directly or view it on GitHub:
https://github.com/codeclimate/codeclimate-services/pull/76/files#r33979971
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that change would be better in finalizer.
without adding in a conditional, it might set the target_url to nil when
@payload["details_url"]
gets left out.
I would test if this matters. If it does, I'd rather that conditional than the one you have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pbrisbin @brynary Hmm. It seems to me that right now, the codeclimate-services
entity is not just getting a payload and relaying it, but making some additional calculations - e.g. formatting messages based on number of issues fixed, adding a context: 'codeclimate'
to params passed to http request.
However, we recently updated finalizer to also do some analysis, including checking whether errored state is due to worker_version incompatibility and adding a unique message to payload, if that's the case.
On one hand, it seems nice for finalizer
(or whatever other entity) to just be able to send a bunch of information to codeclimate-services
github_PR and have cc-services know what to do with it.
On the other hand, it seems nice to have cc-services not know too much about how the stuff it's handling gets calculated - it just knows it needs to send message x to place y.
So, yeah. Agree. Ultimately I favor minimizing analysis in cc-services, which would mean not having it read state
to decide whether to add details_url
or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ABaldwinHunter OK, can you please address this at your convenience?
@codeclimate/review WIP. I wanted to create a more customized message for PR's that error due to incompatible worker versions- particularly engine related.
So, my solution was:
PR: https://github.com/codeclimate/finalizer/pull/49
EDIT: Feedback welcome. It's my first time working with
codeclimate-services
. If my approach seems right, I'll add tests.