Skip to content

In some cases the provider reports: cannot unmarshal number into Go struct field ... of type string #105

Description

@fabian-kramer

Version information

  • terraform: v1.14.8
  • terraform provider: v1.5.1

Describe the bug

In some cases, when components, component groups, or space roles (didn't try on other resources) were modified through Storyblok, it happens that the state can't be refreshed (or imported newly), causing errors like this:
Could not retrieve space_role with id 61617, unexpected error: json: cannot unmarshal number into Go struct field SpaceRole.space_role.allowed_paths of type string

To Reproduce

Create a role similar to this one, best via API:

curl -s -X POST \
    -H "Authorization: $API_KEY" \
    -H "Content-Type: application/json" \
    "https://mapi.storyblok.com/v1/spaces/SPACE_ID/space_roles" \
    -d '{
      "space_role": {
        "role": "bug-test-role",
        "subtitle": "",
        "permissions": [
          "read_stories",
          "save_stories",
          "publish_stories",
          "unpublish_stories",
          "publish_folders",
          "delete_stories",
          "manage-non-translatable-fields"
        ],
        "allowed_paths": [
          325468791,
          343319186
        ],
        "field_permissions": [
        ],
        "allowed_languages": [
          "en-au",
          "en-nz"
        ]
      }
    }'

Try to import into Terraform.

I assume it is also possible to achieve a similar result by updating the allowed_paths list in Storyblok. But the API is easiest to use for demonstration.

Expected behavior

The provider handles all IDs (or number fields in general) regardless of the API sending them as a Number or a String.

Additional context

Add any other context about the problem here.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions