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

Extracted Value configuration in Synthetic Test API Step passes "null" value for the parser of type "raw" #2590

Open
rshah28 opened this issue Sep 23, 2024 · 3 comments
Labels

Comments

@rshah28
Copy link

rshah28 commented Sep 23, 2024

Datadog Terraform Provider Version

3.44.1

Terraform Version

v1.5.3

What resources or data sources are affected?

datadog_synthetics_test

Terraform Configuration Files

resource "datadog_synthetics_test" "availability_check" {
  name      = "Service Availability"
  type      = "api"
  subtype   = "multi"
  locations = var.regions
  message   = var.alert_recipients
  tags      = [local.env_tag]
  status    = "live"

  options_list {
    monitor_name     = "Service Availability"
    monitor_priority = 1
    tick_every       = 60 # run every minute
    retry {
      count    = 2
      interval = 300
    }
    monitor_options {
      renotify_interval = 30
    }
  }

  config_variable {
    type = "global"
    id   = datadog_synthetics_global_variable.user_password[0].id
    name = datadog_synthetics_global_variable.user_password[0].name
  }

  config_variable {
    type = "global"
    id   = datadog_synthetics_global_variable.auth_request_body[0].id
    name = datadog_synthetics_global_variable.auth_request_body[0].name
  }

  api_step {
    name        = "Create Session"
    subtype     = "http"
    is_critical = true

    request_definition {
      method  = "GET"
      url     = var.app_url_for_synthetics
      timeout = 60
    }

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

    extracted_value {
      name  = "AUTH_SESSION_COOKIE"
      type  = "http_header"
      field = "set-cookie"
      parser {
        type  = "regex"
        value = "auth-session=[a-zA-Z0-9]+;"
      }
    }

    extracted_value {
      name  = "AUTHORIZE_URL"
      type  = "http_header"
      field = "location"
      parser {
        type = "raw"
      }
    }
  }
 }
}

Relevant debug or panic output

Error: error updating synthetics API test from /api/v1/synthetics/tests/api/{public_id}: 400 Bad Request: {"errors":["'extractedValues' value '{'field': 'location', 'name': 'AUTHORIZE_URL', 'parser': {'type': 'raw', 'value': ''}, 'secure': False, 'type': 'http_header'}' is invalid"]}

Expected Behavior

Per API docs the "value" config should not be set for the "raw" type parser.
https://docs.datadoghq.com/api/latest/synthetics/#edit-an-api-test

Actual Behavior

It fails to edit the existing Synthetic Test when upgrading the terraform datadog provider version from 3.32.0 to 3.44.1

Steps to Reproduce

terraform apply

Important Factoids

No response

References

No response

@rshah28 rshah28 added the bug label Sep 23, 2024
@Lord-Gusarov
Copy link

Datadog Terraform Provider Version

= 3.39.0

Unable to create or update tests with the extracted_value option and the parser type set to 'raw'. The Provider version had not been changed. Tried with multiple Provider versions and as recent as version 3.44.1

Relevant debug or panic output

Error: error creating synthetics API test from /api/v1/synthetics/tests/api: 400 Bad Request: {"errors":["'extractedValues' value '{'field': 'location', 'name': 'OKTA_REDIRECT_URL', 'parser': {'type': 'raw', 'value': ''}, 'secure': False, 'type': 'http_header'}' is invalid"]}

@Lord-Gusarov
Copy link

Workaround:

Change the parser type to regex and use value .* as the regex.

From:

     extracted_value {
      name  = "AUTHORIZE_URL"
      type  = "http_header"
      field = "location"
      parser {
        type = "raw"
      }

to:

     extracted_value {
      name  = "AUTHORIZE_URL"
      type  = "http_header"
      field = "location"
      parser {
        type = "regex"
        value = ".*"
      }

@rshah28
Copy link
Author

rshah28 commented Oct 14, 2024

@Lord-Gusarov thanks! will give it a try.

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

2 participants