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

using project.id to create a UserRunner fails with 'Expected a Number' #763

Open
dd-ssc opened this issue Dec 5, 2024 · 1 comment
Open
Labels
awaiting-feedback Blocked on input from the author kind/bug Some behavior is incorrect or out of spec

Comments

@dd-ssc
Copy link

dd-ssc commented Dec 5, 2024

Describe what happened

I am trying to create a gitlab.Project and a gitlab.UserRunner for it. My pulumi program:

import pulumi_gitlab as gitlab

project = gitlab.Project('projectResource', name = 'test_gitlab_runner')
runner  = gitlab.UserRunner('runnerResource', runner_type='project_type', project_id=project.id)

The above code fails with

Diagnostics:
  gitlab:index:UserRunner (runnerResource):
    error: cannot encode resource inputs to call ValidateResourceConfig: objectEncoder failed on property "project_id": Expected a Number

I'm using the latest releases:

$ poetry show --top-level)
pulumi        3.142.0 Pulumi's Python SDK
pulumi-gitlab 8.6.1   A Pulumi package for creating and managing GitLab resources.

Could it be that the Project > id output should simply be an int and not a str ?

Happy to provide any further information if required.

Sample program

import pulumi_gitlab as gitlab

project = gitlab.Project('projectResource', name = 'test_gitlab_runner')
runner  = gitlab.UserRunner('runnerResource', runner_type='project_type', project_id=project.id)

Log output

$ pulumi up
Previewing update (test_gitlab_runner)

View in Browser (Ctrl+O): <redacted>

     Type                        Name                                   Plan     Info
     pulumi:pulumi:Stack         test_gitlab_runner-test_gitlab_runner           
     └─ gitlab:index:UserRunner  runnerResource                                  1 error

Diagnostics:
  gitlab:index:UserRunner (runnerResource):
    error: cannot encode resource inputs to call ValidateResourceConfig: objectEncoder failed on property "project_id": Expected a Number

Affected Resource(s)

gitlab.Project; possibly gitlab.UserRunner

Output of pulumi about

$ pulumi about
CLI          
Version      3.142.0
Go Version   go1.23.3
Go Compiler  gc

Plugins
KIND      NAME    VERSION
resource  gitlab  8.6.1
language  python  3.142.0

Host     
OS       darwin
Version  14.7.1
Arch     x86_64

This project is written in python: executable='<redacted>/Library/Caches/pypoetry/virtualenvs/non-package-mode-8gq2fEK2-py3.13/bin/python' version='3.13.0'

Current Stack: dd-ssc/test_gitlab_runner/test_gitlab_runner

TYPE                          URN
pulumi:pulumi:Stack           urn:pulumi:test_gitlab_runner::test_gitlab_runner::pulumi:pulumi:Stack::test_gitlab_runner-test_gitlab_runner
pulumi:providers:gitlab       urn:pulumi:test_gitlab_runner::test_gitlab_runner::pulumi:providers:gitlab::default_8_6_1
gitlab:index/project:Project  urn:pulumi:test_gitlab_runner::test_gitlab_runner::gitlab:index/project:Project::projectResource


Found no pending operations associated with test_gitlab_runner

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/<redacted>
User           <redacted>
Organizations  <redacted>
Token type     personal

Dependencies:
NAME           VERSION
pip            24.2
pulumi_gitlab  8.6.1

Pulumi locates its logs in /var/folders/8t/d1l9tygj3ld643r89wpr3yl80000gn/T/ by default

Additional context

No response

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).

@dd-ssc dd-ssc added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Dec 5, 2024
@VenelinMartinov
Copy link
Contributor

Hi @dd-ssc thanks for reporting and sorry you've hit this. You have correctly identified the source of the problem - Project.id is a string and the input to UserRunner is an int. You can get around this problem by casting the types:

import pulumi_gitlab as gitlab

project = gitlab.Project('projectResource', name = 'test_gitlab_runner')
runner  = gitlab.UserRunner('runnerResource', runner_type='project_type', project_id=action.id.apply(lambda x: int(x)))

https://www.pulumi.com/registry/packages/gitlab/api-docs/userrunner/#projectid_nodejs

I'm afraid that changing the type there would be a breaking change for many users, so it'd be quite difficult to do. Can you please try the workaround of casting the type and let me know if that works?

@VenelinMartinov VenelinMartinov added awaiting-feedback Blocked on input from the author and removed needs-triage Needs attention from the triage team labels Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-feedback Blocked on input from the author kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

2 participants