Skip to content

Commit c9cc90e

Browse files
authored
Merge branch 'master' into maintainer/amanda11
2 parents 60b5404 + 4e932a7 commit c9cc90e

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ Changed
2727

2828
Contributed by @punkrokk
2929

30+
* Added an enhancement where ST2api.log no longer reports the entire traceback when trying to get a datastore value
31+
that does not exist. It now reports a simplified log for cleaner reading. Addresses and Fixes #4979. (improvement) #4981
32+
33+
Contributed by Justin Sostre (@saucetray)
34+
3035
Fixed
3136
~~~~~
3237
* Fixed a bug where `type` attribute was missing for netstat action in linux pack. Fixes #4946

st2common/st2common/exceptions/keyvalue.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414

1515
from __future__ import absolute_import
1616
from st2common.exceptions import StackStormBaseException
17+
from st2common.exceptions.db import StackStormDBObjectNotFoundError
1718

1819
__all__ = [
1920
'CryptoKeyNotSetupException',
21+
'DataStoreKeyNotFoundError',
2022
'InvalidScopeException'
2123
]
2224

@@ -25,6 +27,10 @@ class CryptoKeyNotSetupException(StackStormBaseException):
2527
pass
2628

2729

30+
class DataStoreKeyNotFoundError(StackStormDBObjectNotFoundError):
31+
pass
32+
33+
2834
class InvalidScopeException(StackStormBaseException):
2935
pass
3036

st2common/st2common/persistence/keyvalue.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from st2common.constants.triggers import KEY_VALUE_PAIR_UPDATE_TRIGGER
2020
from st2common.constants.triggers import KEY_VALUE_PAIR_VALUE_CHANGE_TRIGGER
2121
from st2common.constants.triggers import KEY_VALUE_PAIR_DELETE_TRIGGER
22-
from st2common.exceptions.db import StackStormDBObjectNotFoundError
22+
from st2common.exceptions.keyvalue import DataStoreKeyNotFoundError
2323
from st2common.models.api.keyvalue import KeyValuePairAPI
2424
from st2common.models.db.keyvalue import keyvaluepair_access
2525
from st2common.models.system.common import ResourceReference
@@ -112,7 +112,7 @@ def get_by_scope_and_name(cls, scope, name):
112112

113113
if not query_result:
114114
msg = 'The key "%s" does not exist in the StackStorm datastore.'
115-
raise StackStormDBObjectNotFoundError(msg % name)
115+
raise DataStoreKeyNotFoundError(msg % name)
116116

117117
return query_result.first() if query_result else None
118118

st2common/st2common/router.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
from st2common.exceptions import rbac as rbac_exc
3434
from st2common.exceptions import auth as auth_exc
35+
from st2common.exceptions.keyvalue import DataStoreKeyNotFoundError
3536
from st2common import log as logging
3637
from st2common.persistence.auth import User
3738
from st2common.rbac.backends import get_rbac_backend
@@ -513,6 +514,10 @@ def __init__(self, **entries):
513514

514515
try:
515516
resp = func(**kw)
517+
except DataStoreKeyNotFoundError as e:
518+
LOG.warning('Failed to call controller function "%s" for operation "%s": %s' %
519+
(func.__name__, endpoint['operationId'], six.text_type(e)))
520+
raise e
516521
except Exception as e:
517522
LOG.exception('Failed to call controller function "%s" for operation "%s": %s' %
518523
(func.__name__, endpoint['operationId'], six.text_type(e)))

0 commit comments

Comments
 (0)