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

Create issue in Jira is broken #15

Closed
JP-Ellis opened this issue Nov 6, 2023 · 2 comments
Closed

Create issue in Jira is broken #15

JP-Ellis opened this issue Nov 6, 2023 · 2 comments

Comments

@JP-Ellis
Copy link
Contributor

JP-Ellis commented Nov 6, 2023

The workflow which creates tickets in Jira failed earlier.

See the logs here, with the log being:

RequestError [HttpError]: Resource not accessible by integration
    at /home/runner/work/_actions/actions/github-script/v6/dist/index.js:6842:21
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  status: 403,
  response: {
    url: 'https://api.github.com/repos/pact-foundation/pact-python/issues/458/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',
      connection: 'close',
      'content-encoding': 'gzip',
      'content-security-policy': "default-src 'none'",
      'content-type': 'application/json; charset=utf-8',
      date: 'Mon, 06 Nov [20](https://github.com/pact-foundation/pact-python/actions/runs/6766016048/job/18386473095#step:6:21)23 03:39:46 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': '5800:03F6:32425AE:34595F8:65486002',
      'x-ratelimit-limit': '1000',
      'x-ratelimit-remaining': '999',
      'x-ratelimit-reset': '1699245586',
      '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'
    }
  },
  request: {
    method: 'POST',
    url: 'https://api.github.com/repos/pact-foundation/pact-python/issues/458/comments',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'actions/github-script octokit-core.js/3.6.0 Node.js/16.20.2 (linux; x64)',
      authorization: 'token [REDACTED]',
      'content-type': 'application/json; charset=utf-8'
    },
    body: `{"body":"🤖 Great news! We've labeled this issue as <i>smartbear-supported</i> and created a tracking ticket in PactFlow's Jira (<a href='***/browse/PACT-1[45](https://github.com/pact-foundation/pact-python/actions/runs/6766016048/job/18386473095#step:6:46)6'><code>PACT-14[56](https://github.com/pact-foundation/pact-python/actions/runs/6766016048/job/18386473095#step:6:57)</code></a>). We'll keep work public and post updates here. Meanwhile, feel free to check out our <a href='https://docs.pact.io/help/smartbear'>docs</a>. Thanks for your patience!"}`,
    request: { agent: [Agent], hook: [Function: bound bound register] }
  }
}
@Ilia
Copy link
Contributor

Ilia commented Nov 6, 2023

Looks like the github token has expired, so this will still create a Jira ticket, but isn't allowing the script to update the issue with a comment.

Unfortunately, I don't have access to update that token - @mefellows may need your help here :)

@JP-Ellis
Copy link
Contributor Author

TL;DR It was actually my fault. I changed the Pact Python repo's default GitHub token permissions to use least-privilege access (which is also the default for all new repos on GitHub). Turns out, this workflow requires additional privileges which it no longer had, hence the breakage.

The fix is very simple and can be seen in pact-foundation/pact-python#462 and amounts to adding these two lines:

https://github.com/pact-foundation/pact-python/blob/e49ced91903d6b4daec4de37b28f42b8a04fdb8f/.github/workflows/smartbear-issue-label-added.yml#L11-L12

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