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

Unable to use Automation API to install a version of Pulumi #392

Closed
JasonWhall opened this issue Nov 18, 2024 · 2 comments · Fixed by #393
Closed

Unable to use Automation API to install a version of Pulumi #392

JasonWhall opened this issue Nov 18, 2024 · 2 comments · Fixed by #393
Assignees
Labels
area/automation-api kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed

Comments

@JasonWhall
Copy link
Contributor

What happened?

When using the Automation API to install a version of Pulumi, we're currently seeing an error occuring when running the install command to install the Pulumi cli.

Unhandled exception. System.FormatException: Empty string is not a valid version.
   at Semver.SemVersion.Parse(String version, SemVersionStyles style, Int32 maxLength)
   at Pulumi.Automation.PulumiSdkVersionAttribute..ctor(String value)
   at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, RuntimeType type, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
   at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType)
   at Pulumi.Automation.Commands.LocalPulumiCommand.Install(LocalPulumiCommandOptions options, CancellationToken cancellationToken)

Example

Given the following Pulumi program

using Pulumi.Automation.Commands;

await LocalPulumiCommand.Install(new LocalPulumiCommandOptions
{
    Version = new Semver.SemVersion(3, 129, 0),
    Root = "./"
});

Running dotnet run returns the above exception. I would expect this to install version 3.129.0 of the Pulumi cli.

Output of pulumi about

N/A

Additional context

I believe this is because the published binaries do not include an expected Assembly Attribute.

#226 introduced a required Assembly Attributed called PulumiSdkVersion which is obtained during build from the go.mod in the project. However this was only added to the build target and not the publish. Publish runs it's own build step but excludes the required property to set the attribute value -

let buildNugetCmd = String.concat " " [

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

@JasonWhall JasonWhall added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Nov 18, 2024
@justinvp justinvp added area/automation-api and removed needs-triage Needs attention from the triage team labels Nov 20, 2024
@justinvp
Copy link
Member

Thanks for the issue and PR!

github-merge-queue bot pushed a commit that referenced this issue Nov 21, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…on (#393)

Currently when publishing the Pulumi.Automation SDK there is an expected
property PulumiSdkVersion which should be set when building the project

This property is set during buildSdk and testPulumiAutomationSdk but not
the publishing targets which provide the resulting nuget package.

This means when a consumer references the Automation Api nuget package
they have a version that does not have the required property set causing
`LocalPulumiCommand.Install` to fail.

Refactored the F# code to ensure the version is set during publish as
well

Fixes #392
@pulumi-bot pulumi-bot added the resolution/fixed This issue was fixed label Nov 21, 2024
@pulumi-bot
Copy link

This issue has been addressed in PR #393 and shipped in release v3.69.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/automation-api kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants