Pint makes Github API requests returning in`422 Validation Failed` during Pint comment process
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.
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 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
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?