-
Notifications
You must be signed in to change notification settings - Fork 21
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
Posting comment(s) failed at the second run #46
Comments
Getting this error on a public repo makes me think github has changed how a thread's comments are returned. If they switch everything from using Personally, I find the bot comments to be annoying, so I always disable them. |
See from the comments_url: https://api.github.com/repos/shenxianpeng/cpp-linter-action/commits/f4c83bab3681622d96b63bc60abeec966bdf4968/comments, it seems still using
So we could change |
Changing the default value will only abate the issue. I'm not sure why the error is happening. This is what I saw when I looked into the error on the test private repo[
{
"url": "https://api.github.com/repos/shenxianpeng/test-cpp-linter-action/issues/comments/1074807551",
"html_url": "https://github.com/shenxianpeng/test-cpp-linter-action/pull/10#issuecomment-1074807551",
"issue_url": "https://api.github.com/repos/shenxianpeng/test-cpp-linter-action/issues/10",
"id": 1074807551,
"node_id": "IC_kwDOFY2uzM5AEEL_",
"user": {
"login": "github-actions[bot]",
"id": 41898282,
"node_id": "MDM6Qm90NDE4OTgyODI=",
"avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/github-actions%5Bbot%5D",
"html_url": "https://github.com/apps/github-actions",
"followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
"following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
"gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
"starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
"organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
"repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
"events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
"received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
"type": "Bot",
"site_admin": false
},
"created_at": "2022-03-22T07:04:40Z",
"updated_at": "2022-03-22T07:04:40Z",
"author_association": "NONE",
"body_text": "\ud83d\udcdc Run clang-format on the following files\n\n demo.hpp\n demo.cpp\n\n\n\ud83d\udcac Output from clang-tidy\ndemo.hpp\n\ndemo.hpp:10:11: warning: [modernize-use-trailing-return-type]\n\nuse a trailing return type for this function\n\n\n void *not_usefull(char *str){\n ~~~~~~^\n auto -> void *\n\n\n\ndemo.hpp:12:16: warning: [modernize-use-nullptr]\n\nuse nullptr\n\n\n return 0;\n ^\n nullptr\n\n\ndemo.cpp\n\ndemo.cpp:5:5: warning: [modernize-use-trailing-return-type]\n\nuse a trailing return type for this function\n\n\nint main()\n~~~ ^\nauto -> int\n\n\n\ndemo.cpp:7:13: warning: [readability-braces-around-statements]\n\nstatement should be inside braces\n\n\n for (;;)\n ^\n {\n\n\n\ndemo.cpp:10:5: warning: [cppcoreguidelines-pro-type-vararg]\n\ndo not call c-style vararg functions\n\n\n printf(\"Hello world!\\n\");\n ^",
"reactions": {
"url": "https://api.github.com/repos/shenxianpeng/test-cpp-linter-action/issues/comments/1074807551/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
},
"performed_via_github_app": null
},
] |
OK, got your point. The current bug is weird and cannot be reproduced using |
The |
Tested again and found that this issue was caused by When import requests
from requests import Response
class Globals:
response_buffer = Response()
API_HEADERS = {"Accept": "application/vnd.github.v3.text+json",}
# if GITHUB_TOKEN:
# API_HEADERS["Authorization"] = f"token {GITHUB_TOKEN}"
comments_url = 'https://api.github.com/repos/shenxianpeng/cpp-linter-action/commits/f4c83bab3681622d96b63bc60abeec966bdf4968/comments'
Globals.response_buffer = requests.get(comments_url, headers=API_HEADERS)
comments = Globals.response_buffer.json()
for comment in comments:
if (comment["body"].startswith("<!-- cpp linter action -->")):
print("Success") $ python3 test.py
Traceback (most recent call last):
File "test.py", line 17, in <module>
if (comment["body"].startswith("<!-- cpp linter action -->")):
KeyError: 'body' When import requests
from requests import Response
class Globals:
response_buffer = Response()
API_HEADERS = {"Accept": "application/vnd.github.v3.text+json",}
# if GITHUB_TOKEN:
# API_HEADERS["Authorization"] = f"token {GITHUB_TOKEN}"
comments_url = 'https://api.github.com/repos/shenxianpeng/cpp-linter-action/commits/f4c83bab3681622d96b63bc60abeec966bdf4968/comments'
Globals.response_buffer = requests.get(comments_url)
comments = Globals.response_buffer.json()
for comment in comments:
if (comment["body"].startswith("<!-- cpp linter action -->")):
print("Success") $ python3 test.py
Success |
If that's the case, then it should be an easy fix. |
This should resolve #46. It will not affect the fix for private repos since thread comments are now auto-disabled for private repos.
ok I pushed the fix for unnecessarily using a token when fetching the thread comments on the update-thread-comments branch |
post push comments failed when comments exist
More details https://github.com/shenxianpeng/cpp-linter-action/runs/5806368569?check_suite_focus=true
The text was updated successfully, but these errors were encountered: