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

Project Job Token Scopes requests result in 404. #3663

Open
2 tasks done
ScottHarwoodTech opened this issue Dec 4, 2024 · 0 comments
Open
2 tasks done

Project Job Token Scopes requests result in 404. #3663

ScottHarwoodTech opened this issue Dec 4, 2024 · 0 comments

Comments

@ScottHarwoodTech
Copy link

Description

  • Node.js version: 20.18.0
  • Gitbeaker version: 41.3.0
  • Gitbeaker release (cli, rest, core, requester-utils): rest
  • OS & version: MacOS 14.7.1

Trying to call ProjectJobTokenScopes.addToInbountAllowList results in not found.

req Request { 
  method: 'POST', 
  url: 'https://gitlab.com/api/v4/sourceProjectId/job_token_scope/allowlist', 
  headers: Headers {
     'content-type': 'application/json',
     'private-token': '<token>'
   },
   destination: '',
   referrer: 'about:client',
   referrerPolicy: '',
   mode: 'cors',
   credentials: 'same-origin',
   cache: 'default',
   redirect: 'follow',
   integrity: '',
   keepalive: false, 
   isReloadNavigation: false,
   isHistoryNavigation: false,
   signal: AbortSignal { aborted: false } 
} 

file:///Users/*******/node_modules/@gitbeaker/rest/dist/index.mjs:41   throw new GitbeakerRequestError(response.statusText, { 
 GitbeakerRequestError: Not Found

Steps to reproduce

Please find example script attached. This example takes in two known project ids and tries to add the target projectId to the allowlist of the source project. (obviously will require being manually replace in the code snippet)

import { Gitlab } from '@gitbeaker/rest'; 
if (!process.env.GITLAB_PROJECT_ACCESS_TOKEN) {
     throw Error('GITLAB_PROJECT_ACCESS_TOKEN not set');
} 
const api = new Gitlab({
     token: process.env.GITLAB_PROJECT_ACCESS_TOKEN, }); 
export const main = async () => {
     try {
         await api.ProjectJobTokenScopes.addToInboundAllowList("sourceProjectId", "targetProjectId")
     } catch (e: any) {
         console.log("req", e.cause.request)
         throw e
     } 
}
main()

Expected behaviour

Should add the targetProjectId to the source project allow list. As outlined here:
https://docs.gitlab.com/ee/api/project_job_token_scopes.html#add-a-project-to-a-cicd-job-token-inbound-allowlist

Actual behaviour
404

Possible fixes
Looks like the implementation of the ProjectJobTokenScopes Resource is excluding projects from the path for example: here

endpoint`${projectId}/job_token_scope`

should become:

endpoint`projects/${projectId}/job_token_scope`

Checklist

  • I have checked that this is not a duplicate issue.
  • I have read the documentation.
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

1 participant