Skip to content

encoding/json.UnmarshalTypeError on secret_id_ttl #257

@arthur-trt

Description

@arthur-trt

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"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions