terraform-provider-opensearch icon indicating copy to clipboard operation
terraform-provider-opensearch copied to clipboard

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

Open Sovietaced opened this issue 1 year ago • 3 comments

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 avatar Oct 27 '23 02:10 Sovietaced

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

Sovietaced avatar Oct 27 '23 03:10 Sovietaced

[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

prudhvigodithi avatar Nov 05 '23 18:11 prudhvigodithi

[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.

Sovietaced avatar Nov 06 '23 03:11 Sovietaced

Thanks @rblcoder, @Sovietaced closing this issue, please feel-free to re-open or add comments if required. Thank you

prudhvigodithi avatar Sep 17 '24 18:09 prudhvigodithi