Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pint makes Github API requests returning in422 Validation Failed during Pint comment process #919

Closed
akuzni2 opened this issue Mar 19, 2024 · 4 comments

Comments

@akuzni2
Copy link

akuzni2 commented Mar 19, 2024

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[:](https://api.github.com/repos/.../pulls/123/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.

@prymitive
Copy link
Collaborator

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.

@akuzni2
Copy link
Author

akuzni2 commented Mar 27, 2024

@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

@prymitive
Copy link
Collaborator

I've tried to reproduce it but not getting any such error - prymitive/test-pint#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
Copy link
Collaborator

This should be fixed via #1080

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants