ValueError: 'xxx' is not a valid Category from dt.audit_logs.list()
Describe the bug
When calling dt.audit_logs.list() I'm seeing sporadic errors in my logs. The errors I see are ValueError exceptions complaining that specific values are not a valid Category. I am seeing this exception for ACTIVEGATE_TOKEN, ACTIVE_GATE, AGENT, COMPONENT and MANUAL_TAGGING_SERVICE (so far).
-
[ERROR] ValueError: 'ACTIVEGATE_TOKEN' is not a valid Category -
[ERROR] ValueError: 'ACTIVE_GATE' is not a valid Category -
[ERROR] ValueError: 'AGENT' is not a valid Category -
[ERROR] ValueError: 'COMPONENT' is not a valid Category -
[ERROR] ValueError: 'MANUAL_TAGGING_SERVICE' is not a valid Category
Here is an example of the raw exception for your reference:
[ERROR] ValueError: 'MANUAL_TAGGING_SERVICE' is not a valid Category
Traceback (most recent call last):
File "/var/task/collect_audit_events.py", line 39, in lambda_handler
events = dt.audit_logs.list(
File "/opt/python/dynatrace/environment_v2/audit_logs.py", line 41, in list
return PaginatedList(
File "/opt/python/dynatrace/pagination.py", line 37, in __init__
self.__elements = self._get_next_page()
File "/opt/python/dynatrace/pagination.py", line 68, in _get_next_page
data = [self.__target_class(self.__http_client, response.headers, element) for element in elements]
File "/opt/python/dynatrace/pagination.py", line 68, in <listcomp>
data = [self.__target_class(self.__http_client, response.headers, element) for element in elements]
File "/opt/python/dynatrace/dynatrace_object.py", line 35, in __init__
self._create_from_raw_data(raw_element)
File "/opt/python/dynatrace/environment_v2/audit_logs.py", line 83, in _create_from_raw_data
self.category: Category = Category(raw_element.get("category"))
File "/var/lang/lib/python3.10/enum.py", line 385, in __call__
return cls.__new__(cls, value)
File "/var/lang/lib/python3.10/enum.py", line 710, in __new__
raise ve_exc
My assumption here is that additional categories have been added to Dynatrace (SaaS), but the API has not been updated (yet) to include them...
Looking at the Dynatrace API docs, it looks like not all of these are included as valid even though the tenant is returning them...
The latest docs didn't just add some possible values for category it looks like the majority of them were changed or are different, only 'TOKEN' and 'WEB_UI' are still present which is what the original list was.
I'll do some asking/checking to see if these values really are different as opposed to just being added. Either way, just adding these new ones might be the best 'backward compatible' way of doing it. There'd be no risk of supporting values that aren't coming in.
Any luck on tracking down the official list?
Not from the source, but I did add all of the new ones and left the old ones in here for compatibility. I should have closed this when merging but there shouldn't be any issues with the latest releases.
Great, thanks! I'll get it updated on my end and see how it goes!