-
Notifications
You must be signed in to change notification settings - Fork 6
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
ProjectJobTokenScope gives POST error: id is invalid #605
Comments
Hi @SimplicityApks - thank you for filing this issue. We'll take a look as soon as we can. In the meantime, it will help us help you faster if you could provide us with a fully self-contained, minimal Pulumi program that reproduces the issue you're seeing (sensitive data removed)? From reading your issue, I understand there's a manual setting that needs to be tweaked in the UI; please provide those steps as well. |
Thanks for looking into this. It is really simple to reproduce actually: Requirements:
import * as gitlab from "@pulumi/gitlab";
const gitlabProvider = new gitlab.Provider("gitlab", {
token: gitlabCredentials,
baseUrl: "https://gitlaburl.domain",
});
new gitlab.ProjectJobTokenScope(
"urnname",
{
targetProjectId: 36,
project: "mynamespace/myproject",
},
{ provider: gitlabProvider }
); Run pulumi up. -> it errors out with the above error. For the setting I was refeerring to above, it is this one: in https://gitlaburl.domain/mynamespace/myproject/-/settings/ci_cd You can add projects with access regardless of that toggle in the UI, and the toggle I believe is off by default. But gitlab recommends turning that on, haven't found a pulumi way of doing that ;) (sorry I don'- have much time to give you a complete one-click example, but I hope that gives more clarity) |
Hey @SimplicityApks thanks for the details here. I've had a go at this and it looks like the the ProjectJobTokenScope is expecting the ID of the project and not its path. Can you try specifying that and see if resolves your issue? The following program worked fine for me import * as pulumi from "@pulumi/pulumi";
import * as gitlab from "@pulumi/gitlab";
// Create the first GitLab project
const project1 = new gitlab.Project("myproject", {
name: "myproject",
});
// Create the second GitLab project
const project2 = new gitlab.Project("myproject1", {
name: "myproject1",
});
// Create a ProjectJobTokenScope linking the two projects
const projectJobTokenScope = new gitlab.ProjectJobTokenScope("projectJobTokenScope", {
project: project1.id,
targetProjectId: project2.id.apply(id => parseInt(id)),
}); on the other hand, specifying the path with the namespace does not seem to do it and yields the same error you got: import * as pulumi from "@pulumi/pulumi";
import * as gitlab from "@pulumi/gitlab";
// Create the first GitLab project
const project1 = new gitlab.Project("myproject", {
name: "myproject",
});
// Create the second GitLab project
const project2 = new gitlab.Project("myproject1", {
name: "myproject1",
});
// Create a ProjectJobTokenScope linking the two projects
const projectJobTokenScope = new gitlab.ProjectJobTokenScope("projectJobTokenScope", {
project: project1.pathWithNamespace, // ERROR: 400 {error: id is invalid}
targetProjectId: project2.id.apply(id => parseInt(id)),
}); |
Raised https://gitlab.com/gitlab-org/terraform-provider-gitlab/-/issues/6313 upstream for the issue with ProjectJobTokenScope not accepting the path - the docs suggest this should be fine. |
What happened?
Adding a ProjectJobTokenScope does not work. It could be not encoding the id properly
output of pulumi up:
Additionally, I haven't yet found a way to turn on the limit token access allowlist itself. So this has it manually turned on in the UI. Note I also tried before to add the project in the UI, but that should not make a difference I suppose.
Example
code:
pulumi preview detail shows
Output of
pulumi about
CLI
Version 3.115.2
Go Version go1.22.2
Go Compiler gc
Plugins
KIND NAME VERSION
language nodejs unknown
Host
OS debian
Version 11.9
Arch x86_64
This project is written in nodejs: executable='/home/user/.nvm/versions/node/v20.12.2/bin/node' version='v20.12.2'
Current Stack: organization/customer/prod
pulumi gitlab is running in version:
"node_modules/@pulumi/gitlab": {
"version": "6.9.0",
"resolved": "https://registry.npmjs.org/@pulumi/gitlab/-/gitlab-6.9.0.tgz",
"integrity": "sha512-307WjG9haMRzDBE69MPTolGmev95wh7TkyRaIrG0FMS7JUqr0JtWSX/kui5dlklJTY7AJTeao+KFs1x6NmC1XA==",
"dependencies": {
"@pulumi/pulumi": "^3.0.0",
"builtin-modules": "3.0.0",
"read-package-tree": "^5.2.1",
"resolve": "^1.7.1"
}
},
Additional context
We have our own gitlab server, both projects share a group. All other settings (e.g. adding ProjectVariables) via the same provider works fine.
Contributing
Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).
The text was updated successfully, but these errors were encountered: