Terraform-aws-github-runner: EnterpriseServerのChecksAPIに必要なヘッダー

作成日 2021年01月19日  ·  13コメント  ·  ソース: philips-labs/terraform-aws-github-runner

2021-01-19T16:58:27.528Z    784f32d9-df03-522b-86b6-6a58cee71a88    ERROR   RequestError [HttpError]: If you would like to help us test the Checks API during its preview period, you must specify a custom media type in the 'Accept' header. Please see the docs for full details. 

#386が原因と思われる

最も参考になるコメント

リリース0.9.1を作成し

全てのコメント13件

今のところ#386を元に戻すことをお勧めします。

#481で解決

まだこのエラーが発生しています。 昨日、#481がマージされた後、自分でラムダを構築しようとしました。また、リリースされたばかりの0.9.0ラムダzipも同様です。

2021-01-21T18:33:14.240Z    66df9451-e423-5303-ab9e-ccd22f36bbf2    ERROR   RequestError [HttpError]: If you would like to help us test the Checks API during its preview period, you must specify a custom media type in the 'Accept' header. Please see the docs for full details.
    at /var/task/index.js:2756:23
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  status: 415,
  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-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset',
    'alt-svc': 'clear',
    connection: 'close',
    'content-length': '288',
    'content-security-policy': "default-src 'none'",
    'content-type': 'application/json; charset=utf-8',
    date: 'Thu, 21 Jan 2021 18:33:14 GMT',
    'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
    server: 'GitHub.com',
    status: '415 Unsupported Media Type',
    'strict-transport-security': 'max-age=31536000; includeSubdomains',
    via: '1.1 google',
    'x-content-type-options': 'nosniff',
    'x-frame-options': 'deny',
    'x-github-enterprise-version': '2.22.6',
    'x-github-media-type': 'github.v3; format=json',
    'x-github-request-id': '197c6068-c1d5-43d2-9ed4-bb0d409b2500',
    'x-ratelimit-limit': '12500',
    'x-ratelimit-remaining': '12036',
    'x-ratelimit-reset': '1611255703',
    'x-runtime-rack': '0.038530',
    'x-xss-protection': '1; mode=block'
  },
  request: {
    method: 'GET',
    url: 'https://github.example.com/api/v3/repos/acme/somerepo/check-runs/68859',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit-rest.js/18.0.12 octokit-core.js/3.2.4 Node.js/12.20.1 (linux; x64)',
      authorization: 'token [REDACTED]'
    },
    request: { hook: [Function: bound bound register] }
  },
  documentation_url: 'https://docs.github.com/enterprise/2.22/rest/reference/checks#get-a-check-run'
}
server: 'GitHub.com',

あなたはまだあなたのラムダのために古いコミットを使用しています..

いいえ。Githubからダウンロード可能なラムダv0.9.0を実行していると確信しています。 ヘッダーserver: 'GitHub.com'は、当社のGitHubEnterpriseから返されます。

ヘッダーAccept: application/vnd.github.v3+jsonapplication/vnd.github.antiope-preview+jsonではなく送信されている理由は何でしょうか。 ghesApiUrlhttps://github.com/philips-labs/terraform-aws-github-runner/blob/v0.9.0/modules/runners/lambdas/runners/src/scale-runners/で設定されてい

@buamod同じserverヘッダーを取得します。 それは正常なようですか?

@samuelb v0.9.0に修正されたテストの変更を見逃したため、 gh-auth.test.ts L120をローカルで変更しました。

request: mockedRequestInterface.defaults({ baseUrl: githubServerUrl, mediaType: { previews: ['antiope'] } }),

テストに合格しました。

また、octokitでデバッグlog: console,gh-auth.ts L11に挿入され、再コンパイルされ、アップロードされて、次のようになりました。

2021-01-22T13:33:31.960Z    a3e98909-2b21-52b0-9e5c-d18dfd7d23cf    DEBUG   request {
  method: 'GET',
  baseUrl: 'https://githubtest.internal/api/v3',
  headers: {
    accept: 'application/vnd.github.v3+json',
    'user-agent': 'octokit-rest.js/18.0.9 octokit-core.js/3.2.4 Node.js/12.19.0 (linux; x64)'
  },
  mediaType: { format: '', previews: [ 'antiope' ] },
  request: { hook: [Function: bound bound register] },
  url: '/repos/{owner}/{repo}/check-runs/{check_run_id}',
  check_run_id: 845,
  owner: 'ActionsTest',
  repo: 'repo-test'
}

ヘッダーは引き続き渡されますが、新しいmediaTypeが設定されます。

log: console,追加すると、次のようになります。

021-01-22T15:15:21.285Z 68d40d07-e072-55a8-b924-55830e47ae02    DEBUG   request {
  method: 'GET',
  baseUrl: 'https://github.example.com/api/v3',
  headers: {
    accept: 'application/vnd.github.v3+json',
    'user-agent': 'octokit-rest.js/18.0.12 octokit-core.js/3.2.4 Node.js/12.20.1 (linux; x64)'
  },
  mediaType: { format: '', previews: [] },
  request: { hook: [Function: bound bound register] },
  url: '/repos/{owner}/{repo}/check-runs/{check_run_id}',
  check_run_id: 69556,
  owner: 'acme',
  repo: 'somerepo'
}

このmediaTypeは設定されていません。
私は、正しいブランチをチェックアウトすることを2回と3回チェックしました。 私はそれを新鮮にチェックアウトし、ラムダドッカーイメージなどを削除しました。

ユーザーエージェントからわかるように、octokit-rest.jsのバージョンはあなたのバージョンとは異なります。 先ほど、#386を元に戻すことがそれを解決するための1つのオプションであると提案しました。 #481は実際にはその問題を解決しなかったのに、octokit-rest.js / 18.0.9を使用してビルドするときに、誤って修正されたと考えた可能性がありますか?

私の最後のコンパイルはキャッシュされたライブラリを使用していたようです。 私は再コンパイルして、あなたと同じ結果を得ました。

この変更は私のために働いた:
gh-auth.ts L8)

export async function createOctoClient(token: string, ghesApiUrl: string = ''): Promise<Octokit> {
  const ocktokitOptions: OctokitOptions = {
    auth: token,
    log: console,
  };
  if (ghesApiUrl) {
    ocktokitOptions.baseUrl = ghesApiUrl;
    ocktokitOptions.previews = ['antiope'];
  }
  return new Octokit(ocktokitOptions);
}

これが私のために働いていることを確認できます👍

iff --git a/modules/runners/lambdas/runners/src/scale-runners/gh-auth.ts b/modules/runners/lambdas/runners/src/scale-runners/gh-auth.ts
index 01dc3cf..ae3720e 100644
--- a/modules/runners/lambdas/runners/src/scale-runners/gh-auth.ts
+++ b/modules/runners/lambdas/runners/src/scale-runners/gh-auth.ts
@@ -11,6 +11,7 @@ export async function createOctoClient(token: string, ghesApiUrl: string = ''):
   };
   if (ghesApiUrl) {
     ocktokitOptions.baseUrl = ghesApiUrl;
+    ocktokitOptions.previews = ['antiope'];
   }
   return new Octokit(ocktokitOptions);
 }
@@ -51,7 +52,6 @@ export async function createGithubAuth(
   if (ghesApiUrl) {
     authOptions.request = request.defaults({
       baseUrl: ghesApiUrl,
-      mediaType: { previews: ['antiope'] }
     });
   }
   return await createAppAuth(authOptions)({ type: authType });

CloudWatchから:

2021-01-22T16:34:00.464Z    750ac5d2-fd1a-52ff-a26a-9d57fdbb2281    DEBUG   request {
  method: 'GET',
  baseUrl: 'https://github.example.com/api/v3',
  headers: {
    accept: 'application/vnd.github.v3+json',
    'user-agent': 'octokit-rest.js/18.0.12 octokit-core.js/3.2.4 Node.js/12.20.1 (linux; x64)'
  },
  mediaType: { format: '', previews: [ 'antiope' ] },
  request: { hook: [Function: bound bound register] },
  url: '/repos/{owner}/{repo}/check-runs/{check_run_id}',
  check_run_id: 69599,
  owner: 'acme',
  repo: 'somerepo'
}

2021-01-22T16:34:00.841Z    750ac5d2-fd1a-52ff-a26a-9d57fdbb2281    INFO    GET /repos/acme/somerepo/check-runs/69599 - 200 in 377ms

オープン#482

リリース0.9.1を作成し

このページは役に立ちましたか?
0 / 5 - 0 評価