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

Install failure with content-type mismatch #56

Closed
ryanwholey opened this issue May 9, 2022 · 3 comments · Fixed by #57
Closed

Install failure with content-type mismatch #56

ryanwholey opened this issue May 9, 2022 · 3 comments · Fixed by #57

Comments

@ryanwholey
Copy link

We are receiving unexpected Content-Type: "application/vnd+hashicorp.releases-api.v0+json when trying to download Terraform.

Here is a small reproduction example:

go 1.18

require (
	github.com/hashicorp/go-version v1.3.0
	github.com/hashicorp/hc-install v0.3.1
)
// main.go
package main

import (
	"context"
	"log"

	"github.com/hashicorp/go-version"
	install "github.com/hashicorp/hc-install"
	"github.com/hashicorp/hc-install/product"
	"github.com/hashicorp/hc-install/releases"
	"github.com/hashicorp/hc-install/src"
)

func main() {
	v, err := version.NewVersion("1.1.9")
	if err != nil {
		log.Fatal(err)
	}

	installer := install.NewInstaller()

	_, err = installer.Ensure(context.Background(), []src.Source{
		&releases.ExactVersion{
			Product: product.Terraform,
			Version: v,
		},
	})
	if err != nil {
		log.Fatal(err)
	}
}
go run .
2022/05/09 15:10:43 unexpected Content-Type: "application/vnd+hashicorp.releases-api.v0+json"

This can be traced back to

contentType := resp.Header.Get("content-type")
if contentType != "application/json" {
return nil, fmt.Errorf("unexpected Content-Type: %q", contentType)
}

Perhaps the registry API now returns application/vnd+hashicorp.releases-api.v0+json instead of application/json? As a fix, would you be open to getting rid of checking the response header all together? Alternatively we could check both, but since we are handling JSON marshalling errors below, seems like maybe we can just dump this check all together.

@radeksimko
Copy link
Member

Hi @ryanwholey
Thanks for the report. This is indeed related to some recent changes made to the Release API. We're looking into patching the library and cutting a release 🔜

@ryanwholey
Copy link
Author

@radeksimko thank you, much appreciated!

@radeksimko
Copy link
Member

radeksimko commented May 10, 2022

#57 merged and released as part of v0.3.2.

I have also notified the team maintaining https://github.com/hashicorp/terraform-plugin-sdk internally - which is used by most of hc-install downstream consumers, so that Terraform providers can also resume testing 🔜

lego963 added a commit to opentelekomcloud/terraform-provider-opentelekomcloud that referenced this issue May 26, 2022
otc-zuul bot pushed a commit to opentelekomcloud/terraform-provider-opentelekomcloud that referenced this issue May 26, 2022
[Plugin] Fix issue with `Content-Type`

Summary of the Pull Request
Fix issue with Content-Type
PR Checklist

 Refers to: (hashicorp/hc-install#56)

Reviewed-by: Vladimir Vshivkov <None>
Reviewed-by: Anton Sidelnikov <None>
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

Successfully merging a pull request may close this issue.

2 participants