opensearch-project / terraform-provider-opensearch

https://registry.terraform.io/providers/opensearch-project/opensearch
Apache License 2.0
73 stars 56 forks source link

[BUG] Error: invalid character 'U' looking for beginning of value when basic auth credentials are incorrect #115

Open Sovietaced opened 10 months ago

Sovietaced commented 10 months ago

What is the bug?

It appears that the plugin does not handle basic authentication errors gracefully. If invalid credentials are provided there is a confusing error message.

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: invalid character 'U' looking for beginning of value

I haven't looked into the code at all but this appears to be an issue where the code expects valid JSON.

How can one reproduce the bug?

Specify an incorrect username and password with the following provider configuration:

provider "opensearch" {
  url               = "..."
  username          = "..."
  password          = "..."
  healthcheck       = false
  sign_aws_requests = false # Must be set for basic auth
}

What is the expected behavior?

I would expect to see a more helpful error message

Sovietaced commented 10 months ago

It appears this happens when health checking is disabled. If health checking is enabled, a 401 is returned.

prudhvigodithi commented 9 months ago

[Untriage] Thanks @Sovietaced, there are some PR's went in with fix related to basic auth https://github.com/opensearch-project/terraform-provider-opensearch/pull/87 https://github.com/opensearch-project/terraform-provider-opensearch/pull/76, I dont think they fix this invalid character error, can you please take a look and contribute if its a quick fix? Thanks Adding @bbarani @rblcoder

Sovietaced commented 9 months ago

[Untriage] Thanks @Sovietaced, there are some PR's went in with fix related to basic auth #87 #76, I dont think they fix this invalid character error, can you please take a look and contribute if its a quick fix? Thanks Adding @bbarani @rblcoder

Yeah, I will try taking a look at this and report what I find.