{"record":{"id":"fd2f8dbdb3988609","repo":"getsops/sops","slug":"cannot-get-vault-token-w","errorCode":null,"errorMessage":"cannot get Vault token: %w","messagePattern":"cannot get Vault token: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hcvault/keysource.go","lineNumber":424,"sourceCode":"\t\treturn nil, fmt.Errorf(\"Allowlist does not allow %s\", address)\n\t}\n\n\tif hc != nil {\n\t\tcfg.HttpClient = hc\n\t}\n\n\tclient, err := api.NewClient(cfg)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot create Vault client: %w\", err)\n\t}\n\n\tif token != \"\" {\n\t\tclient.SetToken(token)\n\t}\n\t// Provided token takes precedence over the user's token.\n\tif client.Token() == \"\" {\n\t\tif token, err = userVaultToken(); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"cannot get Vault token: %w\", err)\n\t\t}\n\t\tif token != \"\" {\n\t\t\tclient.SetToken(token)\n\t\t}\n\t}\n\n\treturn client, nil\n}\n\n// userVaultToken returns the token from `$HOME/.vault-token` if the file\n// exists. It returns an error if the file exists but cannot be read from.\n// If the file does not exist, it returns an empty string.\nfunc userVaultToken() (string, error) {\n\thomePath, err := homedir.Dir()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error getting user's home directory: %w\", err)\n\t}\n\ttokenPath := filepath.Join(homePath, defaultTokenFile)","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/getsops/sops/blob/13442bb98183887d7a9ac09ec8ab0564673a59d8/hcvault/keysource.go#L406-L442","documentation":"Error \"cannot get Vault token: %w\" thrown in getsops/sops.","triggerScenarios":"Thrown at hcvault/keysource.go:424 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"13442bb98183887d7a9ac09ec8ab0564673a59d8","analyzedAt":"2026-09-01T03:53:00.447Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}