fmt
fmt copied to clipboard
the GITHUB_TOKEN does not have write permission when running `lint.yml` workflow
see https://github.com/fmtlib/fmt/actions/runs/9616362150/job/26526654984
that's why it failed later
RequestError [HttpError]: Resource not accessible by integration
at /home/runner/work/_actions/actions/github-script/e69ef5462fd455e02edcaf4dd7708eda96b9eda0/dist/index.js:9537:21
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/e69ef5462fd455e02edcaf4dd7708eda96b9eda0/dist/index.js:35424:16), <anonymous>:17:1)
at async main (/home/runner/work/_actions/actions/github-script/e69ef5462fd455e02edcaf4dd7708eda96b9eda0/dist/index.js:35518:20) {
status: 403,
response: {
url: 'https://api.github.com/repos/fmtlib/fmt/issues/4032/comments',
status: 403,
headers: {
'access-control-allow-origin': '*',
'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
'content-encoding': 'gzip',
'content-security-policy': "default-src 'none'",
'content-type': 'application/json; charset=utf-8',
date: 'Fri, 21 Jun 2024 16:17:00 GMT',
'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
server: 'GitHub.com',
'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
'transfer-encoding': 'chunked',
vary: 'Accept-Encoding, Accept, X-Requested-With',
'x-accepted-github-permissions': 'issues=write; pull_requests=write',
'x-content-type-options': 'nosniff',
'x-frame-options': 'deny',
'x-github-api-version-selected': '2022-11-28',
'x-github-media-type': 'github.v3; format=json',
'x-github-request-id': '2400:258E93:41503D0:41DD9FA:6675A77C',
'x-ratelimit-limit': '5000',
'x-ratelimit-remaining': '4999',
'x-ratelimit-reset': '1718990220',
'x-ratelimit-resource': 'core',
'x-ratelimit-used': '1',
'x-xss-protection': '0'
},
data: {
message: 'Resource not accessible by integration',
documentation_url: 'https://docs.github.com/rest/issues/comments#create-an-issue-comment',
status: '403'
}
},
request: {
method: 'POST',
url: 'https://api.github.com/repos/fmtlib/fmt/issues/4032/comments',
headers: {
accept: 'application/vnd.github.v3+json',
'user-agent': 'actions/github-script octokit-core.js/5.0.1 Node.js/20.13.1 (linux; x64)',
authorization: 'token [REDACTED]',
'content-type': 'application/json; charset=utf-8'
},
body: '{"body":"clang-format 17.0.5 found issues in the formatting in your code:\\n<details>\\n<summary>\\nView the diff from clang-format:\\n</summary>\\n\\n```diff\\ndiff --git a/include/fmt/format.h b/include/fmt/format.h\\nindex 8f69037..440945d 100644\\n--- a/include/fmt/format.h\\n+++ b/include/fmt/format.h\\n@@ -3918,7 +3918,8 @@ class format_int {\\n mutable char buffer_[buffer_size];\\n char* str_;\\n \\n- template <typename UInt> FMT_CONSTEXPR auto format_unsigned(UInt value) -> char* {\\n+ template <typename UInt>\\n+ FMT_CONSTEXPR auto format_unsigned(UInt value) -> char* {\\n auto n = static_cast<detail::uint32_or_64_or_128_t<UInt>>(value);\\n return detail::format_decimal(buffer_, n, buffer_size - 1).begin;\\n }\\n@@ -3935,9 +3936,12 @@ class format_int {\\n public:\\n explicit FMT_CONSTEXPR format_int(int value) : str_(format_signed(value)) {}\\n explicit FMT_CONSTEXPR format_int(long value) : str_(format_signed(value)) {}\\n- explicit FMT_CONSTEXPR format_int(long long value) : str_(format_signed(value)) {}\\n- explicit FMT_CONSTEXPR format_int(unsigned value) : str_(format_unsigned(value)) {}\\n- explicit FMT_CONSTEXPR format_int(unsigned long value) : str_(format_unsigned(value)) {}\\n+ explicit FMT_CONSTEXPR format_int(long long value)\\n+ : str_(format_signed(value)) {}\\n+ explicit FMT_CONSTEXPR format_int(unsigned value)\\n+ : str_(format_unsigned(value)) {}\\n+ explicit FMT_CONSTEXPR format_int(unsigned long value)\\n+ : str_(format_unsigned(value)) {}\\n explicit FMT_CONSTEXPR format_int(unsigned long long value)\\n : str_(format_unsigned(value)) {}\\n \\n@@ -3958,7 +3962,9 @@ class format_int {\\n }\\n \\n /// Returns the content of the output buffer as an `std::string`.\\n- FMT_CONSTEXPR auto str() const -> std::string { return std::string(str_, size()); }\\n+ FMT_CONSTEXPR auto str() const -> std::string {\\n+ return std::string(str_, size());\\n+ }\\n };\\n \\n template <typename T, typename Char>\\n\\n```\\n\\n</details>\\n"}',
request: {
agent: [Agent],
fetch: [Function: proxyFetch],
hook: [Function: bound bound register]
}
}
}
Error: Unhandled error: HttpError: Resource not accessible by integration
let's compare it with another run with the proper permission, see https://github.com/tchaikov/fmt/actions/runs/9339573823/job/25704121447
so the comment was posted. when the format was wrong.
because, per https://docs.github.com/en/rest/issues/comments?apiVersion=2022-11-28#create-an-issue-comment
The fine-grained token must have at least one of the following permission sets:
- "Issues" repository permissions (write)
- "Pull requests" repository permissions (write)
so we might want to allow workflow to write to an pull request in https://github.com/fmtlib/fmt/settings/actions: