Terraform-aws-github-runner: Cabeçalho necessário para Checks API for Enterprise Server

Criado em 19 jan. 2021  ·  13Comentários  ·  Fonte: 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. 

Provavelmente causado por # 386

Comentários muito úteis

Versão 0.9.1 criada

Todos 13 comentários

Sugiro que revertamos # 386 por enquanto.

Resolvido por # 481

Ainda estou recebendo este erro. Tentei construir os lambdas sozinho ontem depois que o # 481 foi mesclado, bem como os lambda zips 0.9.0 recém-lançados.

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',

você ainda está usando um commit mais antigo para seus Lambdas ..

Não. Tenho certeza de que estou executando o lambdas v0.9.0 que pode ser baixado aqui do Github. O cabeçalho server: 'GitHub.com' é retornado de nossas empresas GitHub Enterprise.

Qual poderia ser o motivo pelo qual o cabeçalho Accept: application/vnd.github.v3+json ainda está sendo enviado em vez de application/vnd.github.antiope-preview+json ? O ghesApiUrl está definido em https://github.com/philips-labs/terraform-aws-github-runner/blob/v0.9.0/modules/runners/lambdas/runners/src/scale-runners/ gh-auth.ts # L51 -L56.

@buamod , recebo o mesmo cabeçalho server . Parece normal?

@samuelb Perdi a modificação do teste para a correção que o trouxe para a v0.9.0, então modifiquei L120 de gh-auth.test.ts localmente:

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

O teste foi aprovado.

Também descobri que você pode habilitar a depuração no octokit. log: console, foi inserido em L11 de gh-auth.ts , recompilado, enviado e produziu isto:

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'
}

O cabeçalho ainda é passado, mas um novo mediaType está definido.

Ao adicionar log: console, , estou recebendo o seguinte:

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'
}

Este mediaType não está definido.
Eu dupliquei e triplamente verifiquei que verifiquei o ramo certo. Eu até verifiquei recentemente, removi a imagem do dock de lambda etc.

Acabei de ver pelo agente do usuário, a versão octokit-rest.js é diferente da sua. Você sugeriu anteriormente que reverter # 386 seria uma opção para resolvê-lo. Será que o # 481 realmente não resolveu esse problema, mas você acidentalmente o considerou corrigido ao compilá-lo usando octokit-rest.js / 18.0.9?

Parece que minha última compilação pode ter usado uma biblioteca em cache. Eu recompilei e obtive o mesmo resultado que você.

Essa modificação funcionou para mim:
( 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);
}

Posso confirmar que isso está funcionando para mim 👍

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 });

Do 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

Inaugurado # 482

Versão 0.9.1 criada

Esta página foi útil?
0 / 5 - 0 avaliações

Questões relacionadas

cmcconnell1 picture cmcconnell1  ·  7Comentários

npalm picture npalm  ·  11Comentários

Kostiantyn-Vorobiov picture Kostiantyn-Vorobiov  ·  6Comentários

mkryva picture mkryva  ·  17Comentários

rjcoupe picture rjcoupe  ·  15Comentários