terraform-provider-http
terraform-provider-http copied to clipboard
Allow specifying the expected Content-Type, to hide the warning
Terraform CLI and Provider Versions
Terraform v1.4.6 on darwin_arm64
- provider registry.terraform.io/hashicorp/http v3.3.0
Use Cases or Problem Statement
╷
│ Warning: Content-Type is not recognized as a text type, got "application/x-pem-file"
│
│ with data.http.mozilla_ca_certificates,
│ on .../ca_certificates.tf line 2, in data "http" "mozilla_ca_certificates":
│ 2: data "http" "mozilla_ca_certificates" {
│
│ If the content is binary data, Terraform may not properly handle the contents of the response.
╵
Proposal
application/x-pem-file is a text type, but the http provider does not recognise it as such and prints a warning. We track warnings emitted by Terraform when it runs under our CI/CD, and would like to eliminate this nuisance warning.
It's not realistic to expect the http provider to know whether any arbitrary MIME type is safe to round-trip through UTF-8, nor is that even generally possible given that there are vendor-defined MIME types.
A more robust solution (rather than just adding application/x-pem-file to the recognised text types) could be to add an attribute such as expected_content_type where the user of the provider can specify what content type they expect to receive. If the content type matches, no warning is emitted. This protects against the server later starting to return another (possibly non-text) content type. The documentation for this attribute could describe the caveat that the response must be text.
How much impact is this issue causing?
Low
Additional Information
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Related: #157
I have even a bit worse problem: the server (and it's github serving releases) does not bother detecting or remembering the content type and simply says application/octet-stream even though the actual content is a valid utf-8-encoded yaml.
A viable workaround would be to dynamically add the types from the accept header (if specified) to the list of supported data types.