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

Error: invalid character '<' looking for beginning of value #364

Closed
ghost opened this issue Nov 25, 2019 · 5 comments
Closed

Error: invalid character '<' looking for beginning of value #364

ghost opened this issue Nov 25, 2019 · 5 comments

Comments

@ghost
Copy link

ghost commented Nov 25, 2019

This issue was originally opened by @calebtote as hashicorp/terraform#23474. It was migrated here as a result of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.12.13

Terraform Configuration Files

# Configure the Datadog provider
provider "datadog" { 
  api_key = "${lookup(local.context_keys[terraform.workspace], "api_key")}"
  app_key = "${lookup(local.context_keys[terraform.workspace], "app_key")}"

  version = "2.5.0"
}

// this is defining all default values for all alert, individual alerts override should be handled locally
locals {
  // we can set a default environment if we want
  env = (terraform.workspace == "default" ? "stable" : terraform.workspace)

  evaluation_delay = lookup(var.evaluation_delay_override, terraform.workspace, 900)
  include_tags = lookup(var.include_tags_override, terraform.workspace, true)
  locked = lookup(var.locked_override, terraform.workspace, true)
  notify = lookup(var.notify_override, terraform.workspace, "@opsgenie-Datadog-SparkTest")
  notify_no_data = lookup(var.notify_no_data_override, terraform.workspace, false)
  require_full_window = lookup(var.require_full_window_override, terraform.workspace, false)
}
locals {

  context_keys = {
    default = {
        api_key = var.default_datadog_api_key
        app_key = var.default_datadog_app_key
    }
    production = {
        api_key = var.prod_datadog_api_key
        app_key = var.prod_datadog_app_key
    }
  }
}

Debug Output

https://gist.github.com/calebtote/92e44ae097f6d6d550ae533c4a4add9e

Expected Behavior

plan succeeds

Actual Behavior

2019/11/22 14:15:20 [TRACE] statemgr.Filesystem: removing lock metadata file .terraform.tfstate.lock.info
Error: invalid character '<' looking for beginning of value
2019/11/22 14:15:20 [TRACE] statemgr.Filesystem: unlocking terraform.tfstate using fcntl flock

  on main.tf line 2, in provider "datadog":
   2: provider "datadog" { 

Steps to Reproduce

  1. terraform init
  2. terraform apply
@rmax
Copy link

rmax commented Nov 26, 2019

I've seen this error when using invalid api keys.

@calebtote
Copy link

Yes, that's what caused the issue for me as well. This needs to be handled more appropriately with proper messaging.

@johnnyplaydrums
Copy link

It's more than just invalid api keys. See dupe issue here: https://github.com/terraform-providers/terraform-provider-datadog/issues/360. My use case is similar to one described in a comment, doing a terraform destroy and there are no datadog resources, we get this error. If at least 1 DD resource was created, the destroy works without error. This also verifies we have correct API keys and that this error can appear for more than just incorrect api keys.

@calebtote
Copy link

We've seen this issue before in our Go apps when endpoints that should return parsable JSON are instead returning an HTML doc (presumably with an error message).

@bkabrda
Copy link
Contributor

bkabrda commented Nov 27, 2019

Hey folks, I think the first part of this error (failing on incorrect API key) has been fixed by PR zorkian/go-datadog-api#282 to the underlying API client. We've already updated the client version on master branch to include that patch, so next release of the provider will have this fixed. I'm going to close this issue and leave tackling the second part (as mentioned by @johnnyplaydrums) for #360.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants