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

encoding/json.UnmarshalTypeError on secret_id_ttl #257

Open
arthur-trt opened this issue Mar 27, 2024 · 1 comment · May be fixed by #260
Open

encoding/json.UnmarshalTypeError on secret_id_ttl #257

arthur-trt opened this issue Mar 27, 2024 · 1 comment · May be fixed by #260

Comments

@arthur-trt
Copy link

arthur-trt commented Mar 27, 2024

Expected Behavior

Trying to write a secret-id of an approle.

Current Behavior

Have a json unmarshall error

Failure Information

Vault binary -> hashicorp/vault:1.15.6
Vault client go -> github.com/hashicorp/vault-client-go v0.4.3

Steps to Reproduce

func writeAppRoleSecretID(
	ctx context.Context,
	client *vault.Client,
	name string,
) (*schema.AppRoleWriteSecretIdResponse, error) {
	response, err := client.Auth.AppRoleWriteSecretId(
		ctx,
		name,
		schema.AppRoleWriteSecretIdRequest{},
		vault.WithMountPath(Config.Content.Vault.Path.AppRole),
	)

	return &response.Data, err
}
error(*encoding/json.UnmarshalTypeError) *{Value: "number", Type: reflect.Type(*reflect.rtype) *{t: (*"internal/abi.Type")(0x104d2cd60)}, Offset: 263, Struct: "AppRoleWriteSecretIdResponse", Field: "data.secret_id_ttl"}

This function will failed because of unmarshall error

Additional Information

curl -s -H "Content-Type: application/json" -H "X-Vault-Token: ${VAULT_TOKEN}" -X POST ${VAULT_ADDR}/v1/auth/approle/role/test/secret-id | jq
{
  "request_id": "945f92f6-79f7-b119-4dfe-f2dcf2447bf6",
  "lease_id": "",
  "renewable": false,
  "lease_duration": 0,
  "data": {
    "secret_id": "b62f3dc0-ecad-08b1-6ae8-c81ca02bb22f",
    "secret_id_accessor": "5298cfca-a7eb-052d-c77f-a647eff4b5f3",
    "secret_id_num_uses": 0,
    "secret_id_ttl": 0
  },
  "wrap_info": null,
  "warnings": null,
  "auth": null
}

When using curl, we can see .data."secret_id_ttl" is a number and not a string. But the API Explorer shown on my vault set secret_id_ttl as a string :

{
  "secret_id": "string",
  "secret_id_accessor": "string",
  "secret_id_num_uses": 0,
  "secret_id_ttl": "string"
}
@arthur-trt
Copy link
Author

The probleme is also present on AppRoleReadRoleResponse and could be on other response schema

@JaniAnttonen JaniAnttonen linked a pull request Apr 12, 2024 that will close this issue
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.

1 participant