Error performing token check: failed to look up namespace from the token: no namespace

my code:

var vaultToken = os.Getenv("VAULT_TOKEN")

var vaultAddr = os.Getenv(“VAULT_ADDR”)
if vaultToken == “” {
return nil, errors.New(“no VAULT_TOKEN”)
}
if vaultAddr == “” {
vaultAddr = “http://127.0.0.1:8200
}

vaultConfig := &vaultApi.Config{
Address: vaultAddr,
}
vaultClient, err := vaultApi.NewClient(vaultConfig)
if err != nil {
return nil, err
}
vaultClient.SetToken(vaultToken)
vc := vaultClient.Logical()

secret, err := vc.Read(“secret/data/gutar”)
if err != nil {
return nil, err
}

Compile and run in a container alpine, error:
Code: 400. Errors:

  • error performing token check: failed to look up namespace from the token: no namespace
    panic: Error making API request.

URL: GET http://127.0.0.1:8200/v1/secret/data/gutar
Code: 400. Errors:

  • error performing token check: failed to look up namespace from the token: no namespace

GET request from the same container:

curl \
>     -X GET \
>     -H "X-Vault-Token: s.MyToken" \
>     http://127.0.0.1:8200/v1/secret/data/gutar;
{"request_id":"f53511a6-ccd3-c202-3b9a-5b44775c808c","lease_id":"","renewable":false,"lease_duration":0,"data":{"data":{"botToken":"botToken"},"metadata":{"created_time":"2020-06-15T06:21:36.600635637Z","deletion_time":"","destroyed":false,"version":1}},"wrap_info":null,"warnings":null,"auth":null}

Most probably your Vault token is bad / corrupted.

Just to be clear: namespace is a feature of Vault Enterprise. Are you using the enterprise version of Vault?

1 Like

Hello,

Usually Vault includes the namespace to which a particular token belongs to, something like s.uviOg94TftCOZWkyexdtxXF2.6SzUR, 6SzUR is the ID of the namespace.

How your s.MyToken looks like in your case?