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

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

Open
runlevel5 opened this issue Mar 14, 2024 · 2 comments

Comments

@runlevel5
Copy link
Collaborator

runlevel5 commented Mar 14, 2024

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

@runlevel5
Copy link
Collaborator Author

runlevel5 commented Mar 14, 2024

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

I will figure out a fix

@muhlba91
Copy link
Collaborator

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.

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

2 participants