mergeable icon indicating copy to clipboard operation
mergeable copied to clipboard

`Validator: INTERNAL ERROR` with complex validation rules

Open Shuiei opened this issue 1 year ago • 1 comments

Hello there, it seems I've encoutered an issue with the mergerable validation file.

image

mergeable.yml:

version: 2
mergeable:
  - when: pull_request.*
    filter:
      - do: payload
        pull_request:
          draft:
            boolean:
              match: false
      - do: author
        must_exclude:
          regex: "dependabot"
    validate:
      - do: or
        validate:
          - do: and
            validate:
              - do: title
                must_include:
                  regex: '^\[([A-Z]+-\d+)\]'
                  message: "Include a ClickUp Ticket ID in the PR title."
              - do: description
                must_exclude:
                  regex: "GOLF-XXXX"
                  message: >
                    Related Issues section needs to be filled in. Please provide a ClickUp ticket ID. ex: [GOLF-1234]
          - do: title
            begins_with: "[NOTICKET]"
            message: "Include [NOTICKET] in the PR title."

Error:

TypeError: supportedSettings[key].includes is not a function
    at Title.validateSettings (/app/lib/validators/validator.js:89:42)
    at Title.processValidate (/app/lib/validators/validator.js:46:12)
    at validateFuncCall (/app/lib/flex/lib/getValidatorPromises.js:4:74)
    at /app/lib/flex/lib/createPromises.js:8:21
    at Array.forEach (<anonymous>)
    at createPromises (/app/lib/flex/lib/createPromises.js:3:18)
    at getValidatorPromises (/app/lib/flex/lib/getValidatorPromises.js:6:10)
    at logicalConnectiveValidatorProcessor (/app/lib/validators/lib/logicalConnectiveValidatorProcessor.js:43:20)
    at Or.validate (/app/lib/validators/or.js:17:12)
    at Or.processValidate (/app/lib/validators/validator.js:57:17)

Shuiei avatar Feb 06 '24 18:02 Shuiei

Hi @Shuiei

I re-created your issue and it seems that you are not using the valid rules for the last one.

Here is how it should be:

version: 2
mergeable:
  - when: pull_request.*
    filter:
      - do: payload
        pull_request:
          draft:
            boolean:
              match: false
      - do: author
        must_exclude:
          regex: "dependabot"
    validate:
      - do: or
        validate:
          - do: and
            validate:
              - do: title
                must_include:
                  regex: '^\[([A-Z]+-\d+)\]'
                  message: "Include a ClickUp Ticket ID in the PR title."
              - do: description
                must_exclude:
                  regex: "GOLF-XXXX"
                  message: >
                    Related Issues section needs to be filled in. Please provide a ClickUp ticket ID. ex: [GOLF-1234]
          - do: title
            begins_with:
              match: ["[NOTICKET]"]
              message: "Include [NOTICKET] in the PR title."

You can compare the difference between your mergeable.yml and mine (begins_with section).

Also you can see how it is specified in the docs.

AlberTajuelo avatar Mar 04 '24 04:03 AlberTajuelo

@AlberTajuelo Thanks! Can't believe I didn't see that. I can close this issue than.

Thanks again =D

Shuiei avatar Mar 08 '24 16:03 Shuiei