pulumiverse/pulumi-buildkite

[bug report] invalid "provider_settings" attribute error when upgrading from v2 to v3

Opened this issue · 2 comments

If you stack is on v2, upon upgrading to v3 you would run into following errors:

error: Unable to Read Previously Saved State for UpgradeResourceState: There was an error reading the saved resource state using the prior resource schema defined for version 0 upgrade.

Please report this to the provider developer:

AttributeName("provider_settings"): invalid JSON, expected "[", got "{"

it turns out that the resource of type buildkite:Pipeline/pipeline:Pipeline has different type for inputs.providerSettings in tf-buildkite in post-v1:

The previous version (prior to v1) used an array of provider settings.

ProviderSettings                     []*providerSettingsModel `tfsdk:"provider_settings"`

Whereas the newer model is a pointer to an object/struct.

ProviderSettings                     *providerSettingsModel `tfsdk:"provider_settings"`

The workaround is modifying the statefile:

  • Update the provider resource from 2 to 3
  • Remove inputs.providerSettings.__defaults
pulumi stack export -s stackName > stateFile.json
# edit the stateFile.json
pulumi stack import -s stackName --file stateFile.json

statefile before:

{
    "urn": "urn:pulumi:platform::buildkite-pipelines::pulumi:providers:buildkite::default_2_2_0_github_/api.github.com/pulumiverse/pulumi-buildkite",
    "custom": true,
    "id": "4c1a2d5b-b292-4eec-ac4a-d4d08cd75be6",
    "type": "pulumi:providers:buildkite",
    "inputs": {
        "pluginDownloadURL": "github://api.github.com/pulumiverse/pulumi-buildkite",
        "version": "2.2.0"
    },
    "outputs": {
        "pluginDownloadURL": "github://api.github.com/pulumiverse/pulumi-buildkite",
        "version": "2.2.0"
    },
    "created": "2023-07-04T07:23:14.026243401Z",
    "modified": "2023-07-04T07:23:14.026243401Z"
},

{
    "urn": "urn:pulumi:platform::buildkite-pipelines::buildkite:Pipeline/pipeline:Pipeline::NAME_HERE",
    "type": "buildkite:Pipeline/pipeline:Pipeline",
    "inputs": {
        "providerSettings": {
            "__defaults": []
        }
    }
}

statefile after:

{
    "urn": "urn:pulumi:platform::buildkite-pipelines::pulumi:providers:buildkite::default_3_1_1_github_/api.github.com/pulumiverse/pulumi-buildkite",
    "custom": true,
    "id": "4c1a2d5b-b292-4eec-ac4a-d4d08cd75be6",
    "type": "pulumi:providers:buildkite",
    "inputs": {
        "pluginDownloadURL": "github://api.github.com/pulumiverse/pulumi-buildkite",
        "version": "3.1.1"
    },
    "outputs": {
        "pluginDownloadURL": "github://api.github.com/pulumiverse/pulumi-buildkite",
        "version": "3.1.1"
    },
    "created": "2023-07-04T07:23:14.026243401Z",
    "modified": "2023-07-04T07:23:14.026243401Z"
},

{
    "urn": "urn:pulumi:platform::buildkite-pipelines::buildkite:Pipeline/pipeline:Pipeline::NAME_HERE",
    "type": "buildkite:Pipeline/pipeline:Pipeline",
    "inputs": {
        "providerSettings": {

        }
    }
}

Ideally we want to provide a seamless way for users to upgrade with a mapper (v2 to v3).

Any thoughts on how to approach this issue @muhlba91

Good news. This issue is known upstream buildkite/terraform-provider-buildkite#501

I will figure out a fix

awesome! 👍🏻

btw. i know there were also some breaking changes around teams, if i remember correctly. so i'd expect issues occuring in minor cases when upgrading to v3.