mergeable
mergeable copied to clipboard
[Documentation error] Payload cannot be used in Validator like specified in the documentation
Hello,
When trying to use your recipe for draft PR, mergeable throws an error saying that validator does not support payload.
Error on mergeable action
Invalid Filters or Validators or Actions
Error: Validators have thrown Error: Cannot find module './validators/payload'
Require stack:
/app/lib/register.js
/app/lib/flex/lib/processWorkflow.js
/app/lib/interceptors/push.js
/app/lib/interceptors/index.js
/app/lib/flex/flex.js
/app/lib/mergeable.js
/app/index.js
/app/node_modules/probot/lib/helpers/resolve-app-function.js
/app/node_modules/probot/lib/run.js
/app/node_modules/probot/lib/index.js
/app/node_modules/probot/lib/bin/probot-run.js
/app/node_modules/probot/bin/probot-run.js
Configuration used (retrieved directly from your documentation):
version: 2
mergeable:
- when: pull_request.*, pull_request_review.*
name: 'Draft check'
validate:
- do: payload
pull_request:
draft:
boolean:
match: false
pass:
- do: comment
payload:
body: This PR is NOT a draft!
fail:
- do: comment
payload:
body: This PR is STILL a draft!
@dgteixeira you are right, thanks for catching this. payload is a filter specific class
@shine2lay , the payload class can capture any field within the GitHub JSON webhook, right?
I've been trying to automate specific actions based on how many licences are left in our GitHub organisation, but unfortunately, that information is not available on the webhooks, at the moment. I've sent customer feedback to GitHub and to our TAM to see if we can get that data within the event JSON.
That way I can trigger some validations and specific actions when the licences are below a specific number, which would be ideal for us :)
I'm having a similar problem. I'm trying to set mergeable to auto-merge prs if some conditions are satisfied. But, when pipeline fails mergeable merge either way. So, I was trying to add a payload validator to ensure that the status is different from failure. But I got the same error.
@shine2lay I'm also having a same problem, using the same check as @dgteixeira. May we know updates to resolve this? Thank you.
@tenshiAMD I don't think I can get to this anytime soon so it'll be hard to say when we will have this implemented. If you want to give it a shot, and create a PR. please ping me so I can help get it merged asap
@shine2lay ok I'm willing to contribute however I do not know what to check, can you provide a guide somehow?
@tenshiAMD I think you'll need to create a new payload class in validators and similar to the payload class in filters, you should go through each entry in payload settings, see if they exist and check if they matches and return the result.
@shine2lay I have thoughts of doing a workaround for now regarding this matter, I think we can just use payload as a filter and just provide empty validators instead like this:
version: 2
mergeable:
- when: pull_request.*, pull_request_review.*
name: 'Draft check'
filter:
- do: payload
pull_request:
draft:
boolean:
match: true
validate: []
pass:
- do: comment
payload:
body: This PR is STILL a draft!
fail:
- do: comment
payload:
body: This PR is NOT a draft!
I still need to test this though. What do you think?
@tenshiAMD you won't get to pass or fail case IIRC. if the filter check doesn't pass, the validation simply doesn't run
@shine2lay I see but in my use case, I just need to check if the PR is draft then do something so if that's the case if the filter is triggered it always passes, correct? Also in my case, I have another check to do the validation
@shine2lay I've already tested something like the example I've given; so far it satisfied my use case. However, the payload validator is still needed though for others to use plus it is breaking this recipe from the documentation site.
@shine2lay I see but in my use case, I just need to check if the PR is draft then do something so if that's the case if the filter is triggered it always passes, correct? Also in my case, I have another check to do the validation
IIRC, if you have an empty array for validate it should always pass.
@shine2lay I've already tested something like the example I've given; so far it satisfied my use case. However, the
payloadvalidator is still needed though for others to use plus it is breaking this recipe from the documentation site.
I believe who ever wrote the recipe made a mistake, we have never supported payload validator so far.
@shine2lay I have thoughts of doing a workaround for now regarding this matter, I think we can just use
payloadas a filter and just provide empty validators instead like this:version: 2 mergeable: - when: pull_request.*, pull_request_review.* name: 'Draft check' filter: - do: payload pull_request: draft: boolean: match: true validate: [] pass: - do: comment payload: body: This PR is STILL a draft! fail: - do: comment payload: body: This PR is NOT a draft!I still need to test this though. What do you think?
I have just tested this filter configuration, but it does not work. As @shine2lay says it always passes since validation has an empty array. @tenshiAMD are you planning to do make a change on it to make validation supports payload?
@munkherdeneen I want to but I do not have enough time to complete this feature. I mostly contribute here by fixing some bugs at the moment. Maybe if @shine2lay makes me one of the maintainers that would give me enough motivation to do so😄