Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

add 401 error message for get secrets in cli

Maidul Islam13a81c9222e2
diff --git a/cli/packages/api/api.go b/cli/packages/api/api.go
index a94be0ab0a..5afec67825 100644
--- a/cli/packages/api/api.go
+++ b/cli/packages/api/api.go
@@ -246,7 +246,11 @@ func CallGetSecretsV3(httpClient *resty.Client, request GetEncryptedSecretsV3Req
}
if response.IsError() {
- return GetEncryptedSecretsV3Response{}, fmt.Errorf("CallGetSecretsV3: Unsuccessful response. Please make sure your secret path, workspace and environment name are all correct [response=%s]", response)
+ if response.StatusCode() == 401 {
+ return GetEncryptedSecretsV3Response{}, fmt.Errorf("CallGetSecretsV3: Request to access secrets with [environment=%v] [path=%v] [workspaceId=%v] is denied. Please check if your authentication method has access to requested scope", request.Environment, request.SecretPath, request.WorkspaceId)
+ } else {
+ return GetEncryptedSecretsV3Response{}, fmt.Errorf("CallGetSecretsV3: Unsuccessful response. Please make sure your secret path, workspace and environment name are all correct [response=%v]", response.RawResponse)
+ }
}
return secretsResponse, nil