cloudflare / pint

Prometheus rule linter/validator
https://cloudflare.github.io/pint/
Apache License 2.0
877 stars 53 forks source link

github reporter ci mode failure #1120

Closed dennybaa closed 1 month ago

dennybaa commented 1 month ago

When comments are present in YAML pint prepares reporter somehow:

appsops/iaas/monitoring/rules/source/vmcluster.yaml:1 Fatal: YAML parser returned an error when reading this file: `error at line 12: invalid group key concurrency`. (yaml/parse)
 1 | # ref: https://raw.githubusercontent.com/VictoriaMetrics/VictoriaMetrics/master/deployment/docker/alerts-cluster.yml****

This this fails:

 level=ERROR msg="Failed to create a new comment" reporter=GitHub path=appsops/iaas/monitoring/rules/source/vmcluster.yaml line=1 err="POST https://api.github.com/repos/p2p-org/iaas-platform/pulls/167/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:}]"
level=ERROR msg="Execution completed with error(s)" err="submitting reports: POST https://api.github.com/repos/p2p-org/iaas-platform/pulls/167/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:}]"

removing comments solves the comment issue. Also could we have ignoring keys configurable such as groups[].labels or groups[].concurency ?

dennybaa commented 1 month ago

image

prymitive commented 1 month ago

When comments are present in YAML pint prepares reporter somehow

The error was because pint tried to create a comment on a unmodified line, which GH API doesn't allow. When you removed some lines the line on which problem is reported became modified and so the problem dissappeared.

This should be fixed with #1123

dennybaa commented 1 month ago

@prymitive Great thank you very much! Could you please share if there are some plans to allow a more relaxed checking (or configurable) so that VictoriaMetrics groups could be scanned?

prymitive commented 1 month ago

https://cloudflare.github.io/pint/#yaml-parser

dennybaa commented 1 month ago

https://cloudflare.github.io/pint/#yaml-parser

@prymitive I don't fully get how. It's not on the rule level, these are group keys which are strictly fixed. See above groups[].labels or groups[].concurency. Thank you very much I'll try :+1: