crossplane-contrib / provider-pagerduty

Apache License 2.0
13 stars 13 forks source link

Provider could not decode JSON response #66

Open tschlaepfer opened 1 month ago

tschlaepfer commented 1 month ago

Today I tested the provider and found that it seams there is an issue with decoding the response from PagerDuty. Applying the following team

apiVersion: team.pagerduty.crossplane.io/v1alpha1
kind: Team
metadata:
  annotations:
  name: test-team
spec:
  deletionPolicy: Delete
  forProvider:
    description: Product and Engineering
    name: Product Development

I get the following error:

cannot run refresh: refresh failed: Error reading PagerDuty team : Could not decode JSON response: json: cannot unmarshal array into Go value of type pagerduty.Team

I got the same error when trying to create a business service. Can someone have a look a this issue?

JoshuaShaver commented 1 month ago

Seeing the same issue - was able to create a User resource with the pagerduty provider, but could not create a Service resource.

fnicolelli-ls commented 4 weeks ago

Hi team, i've the same issue (provider version 0.9.0, 0.8.0 seems fine). I've tried also to debug the issue and, if you use the pod's shell and you go in the /tmp/workspace_id_directory, delete the state and run terraform apply directly, it will successfully create the resource. Every other pagerduty resources that i've tried (orchestration, orchestration router, users etc...) work as expected.

$ terraform apply -auto-approve -input=false -lock=false -json
{"@level":"info","@message":"Terraform 1.5.5","@module":"terraform.ui","@timestamp":"2024-10-24T08:08:55.555178Z","terraform":"1.5.5","type":"version","ui":"1.1"}
{"@level":"info","@message":"pagerduty_team.test-team: Plan to create","@module":"terraform.ui","@timestamp":"2024-10-24T08:08:56.121248Z","change":{"resource":{"addr":"pagerduty_team.test-team","module":"","resource":"pagerduty_team.test-team","implied_provider":"pagerduty","resource_type":"pagerduty_team","resource_name":"test-team","resource_key":null},"action":"create"},"type":"planned_change"}
{"@level":"info","@message":"Plan: 1 to add, 0 to change, 0 to destroy.","@module":"terraform.ui","@timestamp":"2024-10-24T08:08:56.121409Z","changes":{"add":1,"change":0,"import":0,"remove":0,"operation":"plan"},"type":"change_summary"}
{"@level":"info","@message":"pagerduty_team.test-team: Creating...","@module":"terraform.ui","@timestamp":"2024-10-24T08:08:56.576209Z","hook":{"resource":{"addr":"pagerduty_team.test-team","module":"","resource":"pagerduty_team.test-team","implied_provider":"pagerduty","resource_type":"pagerduty_team","resource_name":"test-team","resource_key":null},"action":"create"},"type":"apply_start"}
{"@level":"info","@message":"pagerduty_team.test-team: Creation complete after 0s [id=REDACTED]","@module":"terraform.ui","@timestamp":"2024-10-24T08:08:57.430269Z","hook":{"resource":{"addr":"pagerduty_team.test-team","module":"","resource":"pagerduty_team.test-team","implied_provider":"pagerduty","resource_type":"pagerduty_team","resource_name":"test-team","resource_key":null},"action":"create","id_key":"id","id_value":"REDACTED","elapsed_seconds":0},"type":"apply_complete"}
{"@level":"info","@message":"Apply complete! Resources: 1 added, 0 changed, 0 destroyed.","@module":"terraform.ui","@timestamp":"2024-10-24T08:08:57.447059Z","changes":{"add":1,"change":0,"import":0,"remove":0,"operation":"apply"},"type":"change_summary"}
{"@level":"info","@message":"Outputs: 0","@module":"terraform.ui","@timestamp":"2024-10-24T08:08:57.447200Z","outputs":{},"type":"outputs"}
$ cat terraform.tfstate
{
  "version": 4,
  "terraform_version": "1.5.5",
  "serial": 3,
  "lineage": "13554410-0d46-14f5-623a-687aef24d1fa",
  "outputs": {},
  "resources": [
    {
      "mode": "managed",
      "type": "pagerduty_team",
      "name": "test-team",
      "provider": "provider[\"registry.terraform.io/pagerduty/pagerduty\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "default_role": "manager",
            "description": "Test team",
            "html_url": "https://lansweeper.eu.pagerduty.com/teams/REDACTED",
            "id": "REDACTED",
            "name": "Test Team",
            "parent": null
          },
          "sensitive_attributes": []
        }
      ]
    }
  ],
  "check_results": null
}