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

Cannot unmarshal array into Go struct field PkiListRolesResponse.data.keys of type map[string]interface {} #175

Closed
TheLonelyGhost opened this issue May 24, 2023 · 2 comments · Fixed by #176

Comments

@TheLonelyGhost
Copy link

TheLonelyGhost commented May 24, 2023

Expected Behavior

Attempts to list PKI secrets engine roles using the (*vault.Client).Secrets.PkiListRoles() method succeed with the response object responding to (resp).Data.Keys with a signature of []string, indicating the slice of role names.

Current Behavior

Attempts to list PKI secrets engine roles using the (*vault.Client).Secrets.PkiListRoles() method fail due to the following error:

json: cannot unmarshal array into Go struct field PkiListRolesResponse.data.keys of type map[string]interface {}

Failure Information

Please include the version of Vault binary and the version of vault-client-go you're using.

Vault server: 1.11.4+ent
Vault Client Go: 0.3.2

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Start a copy of Vault (i.e., vault server -dev)
  2. Set environment variables VAULT_ADDR and VAULT_TOKEN accordingly
  3. Enable a PKI secrets engine
  4. Create a role on the enabled PKI mount
  5. Run the code below
// File: example.go
package main

import (
	"context"
	"fmt"

	"github.com/hashicorp/vault-client-go"
)

func main() {
	client, err := vault.New(vault.WithEnvironment())
	if err != nil {
		panic(err)
	}

	out, err := client.Secrets.PkiListRoles(context.Background())
	if err != nil {
		panic(err)
	}

	fmt.Printf("Resp: %v\n", out.Data)
}

Additional Information

The method signature of PkiListRoles() seems like it should follow other, similar "list" type activities, such as AwsListRoles(). The latter has a signature for (*vault.Response[map[string]interface{}]).Data.Keys of []string whereas the former has map[string]interface{}. This might be as minor as having typed {} instead of [] somewhere.

@averche
Copy link
Collaborator

averche commented May 25, 2023

Hi @TheLonelyGhost, thanks for bringing this to our attention!

The root cause of the issue is an incorrect schema type in the generated openapi.json. It should be quite easy to fix. I'm addressing it in hashicorp/vault#20782

@averche
Copy link
Collaborator

averche commented May 26, 2023

This issue should be resolved in v0.3.3.

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