Skip to content

Commit

Permalink
fix: catch InvalidArg when checking maybe_secret (#1332)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmedora authored Nov 18, 2024
1 parent 8e779dd commit 2924202
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion data_validation/secret_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ def maybe_secret(self, project_id: str, secret_id: str, version_id="latest") ->
# Return the decoded payload.
payload = response.payload.data.decode("UTF-8")
return payload
except exceptions.NotFound:
except (exceptions.NotFound, exceptions.InvalidArgument):
# The secret does not exist and therefore we can assume it is just a token to be returned.
return secret_id
5 changes: 3 additions & 2 deletions tests/system/test_secret_manager.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os

import pytest
from data_validation import secret_manager

from data_validation import secret_manager

project_id = os.getenv("PROJECT_ID")

Expand All @@ -20,7 +21,7 @@ def test_access_gcp_secret_exists():
secret_id = "db_test_user"
manager = secret_manager.SecretManagerBuilder().build(client_type)
secret_value = manager.maybe_secret(project_id, secret_id)
assert secret_value == "db_test_user"
assert secret_value == secret_id


def test_access_gcp_secret_not_exists():
Expand Down

0 comments on commit 2924202

Please sign in to comment.