cf-terraforming icon indicating copy to clipboard operation
cf-terraforming copied to clipboard

panic: interface conversion: interface {} is bool, not string when generating `cloudflare_access_application`

Open sashasimkin opened this issue 1 year ago • 1 comments

Confirmation

  • [X] My issue isn't already found on the issue tracker.
  • [X] I have replicated my issue using the latest version of the library and it is still present.

cf-terraforming version

0.20.0

Expected outcome

Resource generated.

Actual outcome

panik

Steps to reproduce

$ cf-terraforming -a *** -t $CLOUDFLARE_API_TOKEN generate --resource-type cloudflare_access_application

panic: interface conversion: interface {} is bool, not string

goroutine 1 [running]:
github.com/cloudflare/cf-terraforming/internal/app/cf-terraforming/cmd.writeAttrLine({0xc00012b778, 0x8}, {0xcbcedc0, 0xc000680e10}, {0x0?, 0xcbd8480?}, 0xc000680c48)
	internal/app/cf-terraforming/cmd/util.go:228 +0xe1d
github.com/cloudflare/cf-terraforming/internal/app/cf-terraforming/cmd.writeAttrLine({0xc00012b778, 0x8}, {0xcbd1da0, 0xc000680b40}, {0x0, 0x0}, 0xc000680c48)
	internal/app/cf-terraforming/cmd/util.go:275 +0x167c
github.com/cloudflare/cf-terraforming/internal/app/cf-terraforming/cmd.init.generateResources.func2(0xd103f40, {0xca66777?, 0x4?, 0xca666f7?})
	internal/app/cf-terraforming/cmd/generate.go:1325 +0x62ae
github.com/spf13/cobra.(*Command).execute(0xd103f40, {0xc000141680, 0x6, 0x8})
	/Users/x/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/[email protected]/command.go:987 +0xab1
github.com/spf13/cobra.(*Command).ExecuteC(0xd104500)
	/Users/x/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/x/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/[email protected]/command.go:1039
github.com/cloudflare/cf-terraforming/internal/app/cf-terraforming/cmd.Execute()
	internal/app/cf-terraforming/cmd/root.go:30 +0x1a
main.main()
	cmd/cf-terraforming/main.go:8 +0xf

I dug into the code a little, and seems like terraforming can't cope with policies.*.reusable (looking at this case https://github.com/cloudflare/cf-terraforming/blob/v0.20.0/internal/app/cf-terraforming/cmd/util.go#L251), here's an excerpt of API response that I received while running with --verbose flag:

{
  "result": [
    {
      "id": "***",
      "uid": "***",
      "type": "warp",
      "name": "Warp Login App",
      "aud": "***",
      "created_at": "2024-07-02T15:17:29Z",
      "updated_at": "2024-08-02T15:47:40Z",
      "domain": "***.cloudflareaccess.com/warp",
      "allowed_idps": [],
      "session_duration": "24h",
      "auto_redirect_to_identity": false,
      "policies": [
        {
          "created_at": "2024-07-02T15:17:29Z",
          "decision": "allow",
          "exclude": [],
          "id": "***",
          "include": [
            {
              "login_method": {
                "id": "***"
              }
            }
          ],
          "name": "Allow access with AWS login",
          "require": [],
          "uid": "***",
          "updated_at": "2024-08-02T15:47:40Z",
          "reusable": false,
          "precedence": 2
        },
        {
          "created_at": "2024-08-02T15:46:23Z",
          "decision": "allow",
          "exclude": [],
          "id": "***",
          "include": [
            {
              "email_domain": {
                "domain": "***"
              }
            }
          ],
          "name": "Allow all @***",
          "require": [],
          "uid": "***",
          "updated_at": "2024-08-02T15:47:40Z",
          "reusable": false,
          "precedence": 3
        }
      ],
      "tags": []
    },
......

References

No response

sashasimkin avatar Aug 05 '24 17:08 sashasimkin