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

[Schema Inaccuracy] Create Or Update A Repository Secret Requires key_id #419

Open
AjkayAlan opened this issue Jun 23, 2021 · 1 comment

Comments

@AjkayAlan
Copy link

AjkayAlan commented Jun 23, 2021

Schema Inaccuracy

Create or Update A Repository Secret currently doesn't require key_id based on the docs. However, the API requires it.

Expected

key_id should be marked as required.

Reproduction Steps

Request without key_id (fails):

Octokit:

const response = await this.makeRequest('PUT /repos/{owner}/{repo}/actions/secrets/{secret_name}', {
  owner: "myorg",
  repo: "myrepo",
  secret_name: "mysecret",
  encrypted_value: "myencryptedvalue",
});

The error:

{
    "errorType": "HttpError",
    "errorMessage": "Invalid request.\n\n\"key_id\" wasn't supplied.",
    "code": 422,
    "name": "HttpError",
    "status": 422,
    "response": {
        "url": "https://api.github.com/repos/myorg/myrepo/actions/secrets/mysecret",
        "status": 422,
        "data": {
            "message": "Invalid request.\n\n\"key_id\" wasn't supplied.",
            "documentation_url": "https://docs.github.com/rest/reference/actions#create-or-update-a-repository-secret"
        }
    },
    "request": {
        "method": "PUT",
        "url": "https://api.github.com/repos/myorg/myrepo/actions/secrets/mysecret",
        "headers": {
            "accept": "application/vnd.github.v3+json",
            "user-agent": "octokit-request.js/5.6.0 Node.js/14.17.0 (linux; x64)",
            "authorization": "token [REDACTED]",
            "content-type": "application/json; charset=utf-8"
        },
        "body": "{\"encrypted_value\":\"TheEncryptedValueHere"}",
        "request": {}
    },
    "stack": [
        "HttpError: Invalid request.",
        "",
        "\"key_id\" wasn't supplied.",
        "    at /var/task/index.js:3:35066",
        "    at processTicksAndRejections (internal/process/task_queues.js:95:5)",
        "    at async XI (/var/task/index.js:5:53816)",
        "    at async DA.addSecretToRepo (/var/task/index.js:100:105846)",
        "    at async Promise.all (index 0)",
        "    at async DA.setSecretsOnRepo (/var/task/index.js:100:105423)",
        "    at async bL (/var/task/index.js:100:106485)",
        "    at async QOe (/var/task/index.js:101:1623)",
        "    at async Runtime.GOe [as handler] (/var/task/index.js:101:1073)"
    ]
}

However, the below request will work:

const keyResponse = await this.makeRequest('GET /repos/{owner}/{repo}/actions/secrets/public-key', {
  owner: "myorg",
  repo: "myrepo",
});

const response = await this.makeRequest('PUT /repos/{owner}/{repo}/actions/secrets/{secret_name}', {
  owner: "myorg",
  repo: "myrepo",
  secret_name: "mysecret",
  encrypted_value: "myencryptedvalue",
  key_id: keyResponse.data.key_id,
});

Related

octokit/request.js#403

@ahoglund
Copy link
Contributor

@AjkayAlan - Thanks for opening this issue, we will add it to our backlog for further triage.

@bruce bruce added the P4 label Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants