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

[FEAT]: Escape slash in request parameters to -- #535

Open
1 task done
HarrierPigeon opened this issue Dec 20, 2022 · 3 comments
Open
1 task done

[FEAT]: Escape slash in request parameters to -- #535

HarrierPigeon opened this issue Dec 20, 2022 · 3 comments
Labels
hacktoberfest Issues for participation in Hacktoberfest Status: Up for grabs Issues that are ready to be worked on by anyone Type: Feature New feature or request
Projects

Comments

@HarrierPigeon
Copy link

HarrierPigeon commented Dec 20, 2022

What happened?

I'm using octokit core inside of a Github Action- and need to pass a string with a slash in it to a request. However, when I do, I get an error like this:

Error
RequestError [HttpError]: Not Found
    at /home/runner/work/_actions/texas-mcallen-mission/actions-secret-modifier/v1.0.24/dist/index.js:2655:21
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async boostrap (/home/runner/work/_actions/texas-mcallen-mission/actions-secret-modifier/v1.0.24/dist/index.js:11488:22) {
  status: 404,
  response: {
    url: 'https://api.github.com/repos/texas-mcallen-mission%2Fdeploy-tester/actions/secrets/TESTING_CLASPRC_JSON',
    status: 404,
...and so on

My code looks something like this:

return this.octokit.request('PUT /:base/:repo/actions/secrets/:name', {
    base: 'repos',
    repo: 'org-name/repository',
    name,
    data
})

this should result in a request that looks like so: /repos/org-name/repository/secrets/chicken_nugget but instead results in a request that looks like this: repos/org-name%2Frepository/secrets/chicken_nugget

Putting in a hard-coded request works, but in the context of a reusable workflow is not an adequate solution.

Here's a not-very-good attempt at a runkit demo:
https://runkit.com/harrierpigeon/63a23af06795d60008aa45c8

References:
https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28#create-or-update-a-repository-secret

Versions

octokit-core.js/4.1.0 Node.js/16.13.0

Relevant log output

Error: Not Found
RequestError [HttpError]: Not Found
    at /home/runner/work/_actions/texas-mcallen-mission/actions-secret-modifier/v1.0.24/dist/index.js:2655:21
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async boostrap (/home/runner/work/_actions/texas-mcallen-mission/actions-secret-modifier/v1.0.24/dist/index.js:11488:22) {
  status: 404,
  response: {
    url: 'https://api.github.com/repos/texas-mcallen-mission%2Fdeploy-tester/actions/secrets/TESTING_CLASPRC_JSON',
    status: 404,
    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: 'Tue, 20 Dec 2022 22:30:18 GMT',
      'github-authentication-token-expiration': '2023-01-15 17:25:01 -0600',
      '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-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': '13C3:4EA3:536BEA:A9DD7B:63A2377A',
      'x-ratelimit-limit': '5000',
      'x-ratelimit-remaining': '4959',
      'x-ratelimit-reset': '1671578539',
      'x-ratelimit-resource': 'core',
      'x-ratelimit-used': '41',
      'x-xss-protection': '0'
    ***
    data: {
      message: 'Not Found',
      documentation_url: 'https://docs.github.com/rest'
    }
  ***
  request: {
    method: 'PUT',
    url: 'https://api.github.com/repos/texas-mcallen-mission%2Fdeploy-tester/actions/secrets/TESTING_CLASPRC_JSON',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit-core.js/4.1.0 Node.js/16.13.0 (linux; x64)',
      authorization: 'token [REDACTED]',
      'content-type': 'application/json; charset=utf-8'
    ***
    body: '{"encrypted_value":"7OGSLEHtRWo8i39xx/Qmi8GMCxGc5VRbvoZscp4/R35OQi2DrJS8F8adf1k5laQIVhEhRc0JXPdN6YmofRjUNcSqJDRelRHuTl+aq38tWykEh6D0e2aXHVYgn+jk83DFm30j4QJuJ9M+iOpBVrb3cCai93Z8uoryXPIsTdPF1e1Jaik2dPjAIH5BKgFLL8xvZ+bCFvff7qZZ0oIbOkc5psR24h97wgF6I+SScPQintDmSt/BIrX7EEef2kEwc3cnDBWJ4qnXGmiKW1AxhKWMv9uPfpZu2aNlh0tZkePS+UVm4OF4m4WPJ04CldgIje90VIVmfl3ZK/raImPss76rywHc8ujC8+QTDnBO34POJWuaEw9Nv5PEs2Asqd+I7jh4s7bR7Ce7xoqQqjdvPUD4mciEjzDtYc4FYptn0UPQx5nZvqP2obEbitIDvRPbSH2AviCp2U9+I4xwHHQP4RJUZ0IbnJcq3SJMX5luBf+z6VsCcmKTFNjteDNdbL3CHwO2KOR+d28lRiBImmuvtONAV7zxvQ8GzKL3O3k/4o4L/FGgbzi//Vi7m7QpBeCblQJIaXI7ttfc2S0PEGPpHOcvZlxO0qM1vb8PAfdKh+DAuDNknuzUujblOSvUbGY7LFOcnggcVGU+JpJWgZBLJOXzEwfUH3xEVlsB0tTwMnnrclmN3cw9TU4qZC5/n85e5L7PpE++looa8DeWFe70wCRumMIdw8UU5EZfPbquNZMgg0cb/fXnW65W2J+edAzv+6BrPoAyYy3R2XCKEUMCA9BH4YsW7pQOSbH3WtV0SMJJJxkXUhvze8+Uf56chscSMDFTuiyJnd+CwMg1+3O/EvGjJcKfJeeZISxf4BwciNJOFMka3/NzybPDmAXo7zL8yZeRNKEhiKbI2WukwDDkXZlDcJ8ntrrmc78/2gki3qv6izUEpgRXMNY5yLQF0lQRnt3Xm3gLK7x+y8K2tX5hjve2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CbmM8Vx4BUH8UZSA9VGRfJ8mhkn43F7MNM2pULzS6xBOjwGnDwFblZhGd0duOQPzsewIkAZ4/1FyepsZoEczn7yUN1A/FeziA=","key_id":"568250167242549743"}',
    request: { hook: [Function: bound bound register] }
  }
}

Code of Conduct

  • I agree to follow this project's Code of Conduct
@HarrierPigeon HarrierPigeon added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Dec 20, 2022
@ghost ghost added this to Bugs in JS Dec 20, 2022
@wolfy1339
Copy link
Member

Can you try updating your code like so, and see if that helps

return this.octokit.request('PUT /{base}/{repo}/actions/secrets/{name}', {
    base: 'repos',
    repo: 'org-name/repository',
    name,
    data
})

@HarrierPigeon
Copy link
Author

HarrierPigeon commented Dec 21, 2022

Can you try updating your code like so, and see if that helps

return this.octokit.request('PUT /{base}/{repo}/actions/secrets/{name}', {
    base: 'repos',
    repo: 'org-name/repository',
    name,
    data
})
response: {
    url: 'https://api.github.com/repos/texas-mcallen-mission%2Fdeploy-tester/actions/secrets/TESTING_CLASPRC_JSON',
    status: 404,
    headers: {

I had the same failure again.

@HarrierPigeon
Copy link
Author

I was, however, able to get things to work if I did the following:

let demoString = 'org--name/repository'
let split = demoString.split('/')
return this.octokit.request('PUT /{base}/{repo}/{owner}/actions/secrets/{name}', {
    base: 'repos',
    owner: split[0],
    repo: split[1],
    name,
    data
})

So now I have a solution that works; however I'd still really like to see if there's a way to change the default behavior of converting things to %2F (maybe a interpret_string_literally flag or something? I dunno)

@wolfy1339 wolfy1339 added Type: Feature New feature or request Priority: Normal and removed Type: Bug Something isn't working as documented Status: Triage This is being looked at and prioritized labels Dec 21, 2022
@ghost ghost moved this from Bugs to Features in JS Dec 21, 2022
@wolfy1339 wolfy1339 changed the title [BUG]: slash in variable converts to %2F in request [FEAT]: Escape slash in request parameters to -- Dec 21, 2022
@wolfy1339 wolfy1339 added the Status: Up for grabs Issues that are ready to be worked on by anyone label Jan 18, 2023
@nickfloyd nickfloyd added the hacktoberfest Issues for participation in Hacktoberfest label Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest Issues for participation in Hacktoberfest Status: Up for grabs Issues that are ready to be worked on by anyone Type: Feature New feature or request
Projects
Status: 🔥 Backlog
JS
  
Features
Development

No branches or pull requests

4 participants
@nickfloyd @wolfy1339 @HarrierPigeon and others