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

Unable to create datadog_synthetics_test with validatesJSONPath block and isUndefined operator #1963

Closed
sachams opened this issue Jun 13, 2023 · 2 comments
Labels

Comments

@sachams
Copy link

sachams commented Jun 13, 2023

Terraform Version

Terraform v1.5.0
on linux_arm64

DataDog/datadog 3.26.0

Affected Resource(s)

  • datadog.datadog_synthetics_test

Terraform Configuration Files

resource "datadog_synthetics_test" "example_synthetic_test" {
  name      = "monitor-name"
  message   = "message"
  locations = ["aws:eu-central-1"]
  status    = "live"
  subtype   = "multi"
  type      = "api"

  options_list {
    accept_self_signed              = "false"
    allow_insecure                  = "false"
    check_certificate_revocation    = "false"
    disable_cors                    = "false"
    disable_csp                     = "false"
    follow_redirects                = "false"
    ignore_server_certificate_error = "false"
    initial_navigation_timeout      = "0"
    min_failure_duration            = "0"
    min_location_failed             = "1"

    monitor_options {
      renotify_interval = "0"
    }

    no_screenshot    = "false"

    retry {
      count    = "0"
      interval = "300"
    }

    tick_every = "60"
  }

  api_step {
    name    = "Generic name"
    subtype = "http"

    request_definition {
      method = "GET"
      url    = "http://mockserver:8080/api/rest/status"
    }

    assertion {
      operator = "lessThan"
      target   = "10000"
      type     = "responseTime"
    }

    assertion {
      operator = "is"
      target   = "200"
      type     = "statusCode"
    }

    assertion {
      operator = "validatesJSONPath"
      type     = "body"
      targetjsonpath {
        jsonpath    = "$.mesage"
        operator    = "isUndefined"
      }
    }
  }
}

Debug Output

Please provide a link to a GitHub Gist containing the complete debug output:

https://gist.github.com/sachams/e30c9570605c0fe4b87c91cf0b269b51

Panic Output

None

Expected Behavior

The synthetic test should have been provisioned in DataDog

Actual Behavior

An error was produced:

module.datadog.datadog_synthetics_test.example_synthetic_test: Creating...
╷
│ Error: error creating synthetics API test from https://api.datadoghq.eu/api/v1/synthetics/tests/api: 400 Bad Request: {"errors":["0.type: '' is not of type 'number'\n\nFailed validating 'type' in schema[0]:\n    {'type': 'number'}\n\nOn instance:\n    ''"]}
│ 
│   with module.datadog.datadog_synthetics_test.example_synthetic_test,
│   on ../../../modules/datadog_e2e/example.tf line 1, in resource "datadog_synthetics_test" "example_synthetic_test":
│    1: resource "datadog_synthetics_test" "example_synthetic_test" {
│ 
╵

Steps to Reproduce

Run terraform apply on the above configuration.

Important Factoids

If I remove the assertion block with the validatesJSONPath condition, it works fine:

module.datadog.datadog_synthetics_test.example_synthetic_test: Creating...
module.datadog.datadog_synthetics_test.example_synthetic_test: Creation complete after 0s [id=qqd-nf9-q2a]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

References

This issue is very like this one which was closed. In fact, the example terraform config is taken from that example.

@therve
Copy link
Contributor

therve commented Jun 13, 2023

Hi,

I managed to reproduce. Indeed the previous PR didn't fix the issue, as the value is now optional but an empty string is still passed to the backend which causes the error you see. We'll write a fix, thanks for your patience.

@therve therve changed the title BUG: unable to create datadog_synthetics_test with validatesJSONPath block Unable to create datadog_synthetics_test with validatesJSONPath block and isUndefined operator Jun 13, 2023
@therve therve added the bug label Jun 13, 2023
@nkzou
Copy link
Contributor

nkzou commented Jun 22, 2023

Closed by #1966 . The next release is planned for early July. Thanks for reporting the issue!

@nkzou nkzou closed this as completed Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants