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

Allow specifying the expected Content-Type, to hide the warning #266

Open
1 task done
jbg opened this issue May 10, 2023 · 3 comments
Open
1 task done

Allow specifying the expected Content-Type, to hide the warning #266

jbg opened this issue May 10, 2023 · 3 comments

Comments

@jbg
Copy link

jbg commented May 10, 2023

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

  • I agree to follow this project's Code of Conduct
@bendbennett
Copy link
Contributor

Related: #157

@jan-hudec
Copy link

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.

@crabique
Copy link

crabique commented Jun 2, 2023

A viable workaround would be to dynamically add the types from the accept header (if specified) to the list of supported data types.

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

No branches or pull requests

4 participants