Skip to content

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

Fix: JSON error check

Daniel Hougaardcb6cbafcaedc
diff --git a/cli/test/export_test.go b/cli/test/export_test.go
index 8c4b49ef19..dd156fc392 100644
--- a/cli/test/export_test.go
+++ b/cli/test/export_test.go
@@ -31,7 +31,10 @@ func ExportSecrets(t *testing.T, authToken string, projectId string, envSlug str
var secrets []models.SingleEnvironmentVariable
- json.Unmarshal(commandOutput.Bytes(), &secrets)
+ err := json.Unmarshal(commandOutput.Bytes(), &secrets)
+ if err != nil {
+ t.Errorf("Error: %v", err)
+ }
expectedLength := len(ALL_SECRETS) - 1 // -1 because the default path is "/", and the secret in /folder will not be found.
@@ -68,7 +71,10 @@ func ExportSecretsWithoutImports(t *testing.T, authToken string, projectId strin
var secrets []models.SingleEnvironmentVariable
- json.Unmarshal(commandOutput.Bytes(), &secrets)
+ err := json.Unmarshal(commandOutput.Bytes(), &secrets)
+ if err != nil {
+ t.Errorf("Error: %v", err)
+ }
assert.Len(t, secrets, len(DEV_SECRETS))
diff --git a/cli/test/secrets_test.go b/cli/test/secrets_test.go
index b346a3e69f..39bfd1c07d 100644
--- a/cli/test/secrets_test.go
+++ b/cli/test/secrets_test.go
@@ -33,7 +33,10 @@ func ListSecretsWithImportsAndRecursive(t *testing.T, authToken string, projectI
var secrets []models.SingleEnvironmentVariable
- json.Unmarshal(commandOutput.Bytes(), &secrets)
+ err := json.Unmarshal(commandOutput.Bytes(), &secrets)
+ if err != nil {
+ t.Errorf("Error: %v", err)
+ }
if len(secrets) == 0 {
t.Errorf("No secrets found")
@@ -79,7 +82,10 @@ func GetSecretsByNames(t *testing.T, authToken string, projectId string, envSlug
var secrets []models.SingleEnvironmentVariable
- json.Unmarshal(commandOutput.Bytes(), &secrets)
+ err := json.Unmarshal(commandOutput.Bytes(), &secrets)
+ if err != nil {
+ t.Errorf("Error: %v", err)
+ }
assert.Len(t, secrets, len(ALL_SECRETS))