Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: 'xxx' is not a valid Category from dt.audit_logs.list() #89

Closed
JosephHobbs opened this issue Sep 3, 2024 · 4 comments
Closed
Labels
bug Something isn't working

Comments

@JosephHobbs
Copy link

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...

@JosephHobbs JosephHobbs added the bug Something isn't working label Sep 3, 2024
@JosephHobbs
Copy link
Author

Looking at the Dynatrace API docs, it looks like not all of these are included as valid even though the tenant is returning them...

image

@Dynatrace-James-Kitson
Copy link
Collaborator

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.

@JosephHobbs
Copy link
Author

Any luck on tracking down the official list?

@Dynatrace-James-Kitson
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants