Comments (8)
Tested again and found that this issue was caused by headers=API_HEADERS
. So the public repository might don't need to pass in headers.
When headers=API_HEADERS
exist, reproduce the error
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 headers=API_HEADERS
not exist, run again, success.
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
from cpp-linter-action.
If that's the case, then it should be an easy fix.
from cpp-linter-action.
ok I pushed the fix for unnecessarily using a token when fetching the thread comments on the update-thread-comments branch
from cpp-linter-action.
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 body
to body_text
field, then we may not be able to continue using an HTML comment to identify a bot's comment from other actions' bot comments.
Personally, I find the bot comments to be annoying, so I always disable them.
from cpp-linter-action.
See from the comments_url: https://api.github.com/repos/shenxianpeng/cpp-linter-action/commits/f4c83bab3681622d96b63bc60abeec966bdf4968/comments, it seems still using body
Personally, I find the bot comments to be annoying, so I always disable them.
So we could change thread-comments
default value to false
. your thoughts?
from cpp-linter-action.
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
},
]
from cpp-linter-action.
OK, got your point. The current bug is weird and cannot be reproduced using comments_url
https://api.github.com/repos/shenxianpeng/cpp-linter-action/commits/f4c83bab3681622d96b63bc60abeec966bdf4968/comments
from cpp-linter-action.
The comments_url
is slightly different for PR vs push events. If I had to guess, I'd say the remove_bot_comments()
is iterating over the fetched thread comments incorrectly??
from cpp-linter-action.
Related Issues (20)
- apt-get is missing -y and gets stuck due to interactive mode HOT 6
- Update README about new step-summary and revised thread comments HOT 3
- Update thread comment once format checks are successful. HOT 4
- Improve paths handling HOT 2
- .clang-tidy is not considered HOT 2
- How to specify "Build path" (`-p`) for .clang-tidy? HOT 2
- Option to only post thread comment when errors are detected HOT 14
- Warning: 2 File(s) not formatted (should be 1) HOT 3
- How to make cpp-linter-action work with Conan? HOT 5
- Seperate output for `clang-format` and `clang-tidy` HOT 5
- Python `error: externally-managed-environment` during installation HOT 32
- _pygit2.GitError: repository path '/__w/Waybar/Waybar/' is not owned by current user HOT 6
- [BUG][v2.7.4] _pygit2.GitError: trailing data at line 3734 HOT 12
- Preparing for v2.9.0 PR review feature release HOT 8
- State what python version is used in README HOT 8
- create an examples folder to demonstrate various usage HOT 2
- generate the "Inputs and Outputs" page using action.yml
- cpp-linter workflows runs for every change HOT 9
- Incorrectly added `latest` tag for PR testing and not trigger test action HOT 2
- unexpected `minimun-version` field on latest v2 release HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpp-linter-action.