DataDog / terraform-provider-datadog

Terraform Datadog provider
https://www.terraform.io/docs/providers/datadog/
Mozilla Public License 2.0
399 stars 375 forks source link

API Multi-step Synthetics test creation failed with `extracted_value` #2531

Closed nakamiri closed 1 month ago

nakamiri commented 1 month ago

Datadog Terraform Provider Version

v3.43.0

Terraform Version

v1.9.4

What resources or data sources are affected?

datadog_synthetics_test

Terraform Configuration Files

terraform {
  required_providers {
    datadog = {
      source = "DataDog/datadog"
      version = ">= 3.39.0"
    }
  }
}

variable "datadog_api_key" {}
variable "datadog_app_key" {}

provider "datadog" {
  api_key = var.datadog_api_key
  app_key = var.datadog_app_key
}

resource "datadog_synthetics_test" "name" {
  name      = "[TEST] dummy synthetic"
  type      = "api"
  subtype   = "multi"
  status    = "paused"
  locations = ["gcp:asia-northeast1"]

  options_list {
    tick_every = 3600
  }

  api_step {
    name = "Test https://google.com"
    subtype = "http"

    request_definition {
      method = "GET"
      url = "https://google.com"
    }

    extracted_value {
      name = "TEST"
      type = "http_body"
      parser {
        type = "json_path"
        value = "$.dummy"
      }
    }
  }
}

Relevant debug or panic output

datadog_synthetics_test.name: Creating...
╷
│ Error: error creating synthetics API test from /api/v1/synthetics/tests/api: 400 Bad Request: {"errors":["'extractedValues' value '{'field': '', 'name': 'TEST', 'parser': {'type': 'json_path', 'value': '$.dummy'}, 'secure': False, 'type': 'http_body'}' is invalid"]}
│ 
│   with datadog_synthetics_test.name,
│   on main.tf line 18, in resource "datadog_synthetics_test" "name":
│   18: resource "datadog_synthetics_test" "name" {
│ 
╵
❯ terraform -version
Terraform v1.9.4
on darwin_arm64
+ provider registry.terraform.io/datadog/datadog v3.43.0

Expected Behavior

The request payload is invalid. The field param may be unnecessary and should not exist when extracted_value is set with http_body.

Actual Behavior

The request payload is created with the field: "".

{
  "config": {
    "assertions": [],
    "configVariables": [],
    "steps": [
      {
        "allowFailure": false,
        "assertions": [],
        "extractedValues": [
          {
            "field": "",
            "name": "TEST",
            "parser": { "type": "json_path", "value": "$.dummy" },
            "secure": false,
            "type": "http_body"
          }
        ],
        "isCritical": false,
        "name": "Test https://google.com",
        "request": {
          "allow_insecure": false,
          "follow_redirects": false,
          "httpVersion": "any",
          "method": "GET",
          "noSavingResponseBody": false,
          "persistCookies": false,
          "timeout": 0,
          "url": "https://google.com"
        },
        "subtype": "http"
      }
    ]
  },
  "locations": ["gcp:asia-northeast1"],
  "message": "",
  "name": "[TEST] dummy synthetic",
  "options": {
    "httpVersion": "any",
    "min_location_failed": 1,
    "tick_every": 3600
  },
  "status": "paused",
  "subtype": "multi",
  "tags": [],
  "type": "api"
}

Steps to Reproduce

Using pasted tf file and terraform apply.

This also occurs if other params with extracted_values are set.

Important Factoids

No response

References

No response

dreinhardt89 commented 1 month ago

Same issue

nrowegt commented 1 month ago

This showed up today for me provider 3.43.0. I tried 3.42.0 and 3.41.0, which also all failed with the same message.

Of note - These synthetics were valid on 3.42.0 when I created them on Monday (Aug 12, 2024). But an attempt to recreate with the provider pinned to 3.42.0 today failed.

sabukittu commented 1 month ago

We're experiencing the same issue as well.


│ Error: error creating synthetics API test from https://api.datadoghq.eu/api/v1/synthetics/tests/api: 400 Bad Request: {"errors":["'extractedValues' value '{'field': '', 'name': 'PUBLIC', 'parser': {'type': 'json_path', 'value': '$.access'}, 'secure': False, 'type': 'http_body'}' is invalid"]}
│
│   with datadog_synthetics_test.white_label["test"],
│   on dd_synthetics_test_white_label.tf line 43, in resource "datadog_synthetics_test" "white_label":
│   43: resource "datadog_synthetics_test" "white_label" {
│

Terraform v1.8.4
on linux_amd64
+ provider registry.terraform.io/datadog/datadog v3.39.0
Drarig29 commented 1 month ago

Hi! This will be fixed by https://github.com/DataDog/terraform-provider-datadog/pull/2533. Sorry for the inconvenience.