pint icon indicating copy to clipboard operation
pint copied to clipboard

Pint makes Github API requests returning in`422 Validation Failed` during Pint comment process

Open akuzni2 opened this issue 1 year ago • 3 comments

There seems to be a scenario where Pint cannot make a correct comment on PR.

level=ERROR msg=“Execution completed with error(s)” err=“submitting reports: POST https://api.github.com/repos/.../comments: 422 Validation Failed [{Resource:PullRequestReviewComment Field:pull_request_review_thread.line Code:custom Message:pull_request_review_thread.line must be part of the diff} {Resource:PullRequestReviewComment Field:pull_request_review_thread.diff_hunk Code:missing_field Message:}]”

The message

Message:pull_request_review_thread.line must be part of the diff

Indicates that Pint is trying to leave a comment where it shouldn't

The message

Field:pull_request_review_thread.diff_hunk Code:missing_field

indicates the API request had a missing field.

Github Rest API docs for missing_field Validation Failed for

A parameter that was required was not specified. Review the documentation for the endpoint to see what parameters are required.

akuzni2 avatar Mar 19 '24 19:03 akuzni2

I don't really use pint with GitHub, so unless you can provide more details or (better) a way to reproduce it there isn't much I can do here unfortunately.

prymitive avatar Mar 25 '24 17:03 prymitive

@prymitive thanks for the response - we had someone look a bit into the pint code and they shared this tidbit

that the problem is the algorithm thats used for multi-line expressions, if the Github Diff doesn't contain the line where the expr: starts, it fails

How you'd reproduce would be to create an alert with a multi-line expression like so:

groups:
- name: example_alerts
  rules:
  - alert: HighCpuUsage
    expr: |
      avg by (instance) (
        rate(node_cpu_seconds_total{mode!="idle"}[5m])
      ) * 100 > 70
    for: 5m
    labels:
      severity: critical

If you make a PR against this alert - an change a line thats not on the same line as expr: it should fail. For instance if you change the threshold from 70 -> 60

akuzni2 avatar Mar 27 '24 22:03 akuzni2

I've tried to reproduce it but not getting any such error - https://github.com/prymitive/test-pint/pull/58.

Is it promql/series that's triggering comments here or something else? Are you using latest pint? If not can you retest with latest version please?

prymitive avatar Mar 28 '24 09:03 prymitive