Skip to content

Accept a single event type in user group audit filters - #2097

Open
Mohith26 wants to merge 1 commit into
Labelbox:developfrom
Mohith26:mg/audit-events-single-type
Open

Mohith26 wants to merge 1 commit into
Labelbox:developfrom
Mohith26:mg/audit-events-single-type

Conversation

@Mohith26

@Mohith26 Mohith26 commented Nov 3, 2026 •

Copy link
Copy Markdown

Description

UserGroup.audit_events(types=...) and UserGroup.get_audit_events(client, types=...) take an iterable of event types. Passing a single type, either "MEMBER_ADDED" or UserGroupAuditEventType.MEMBER_ADDED (a str enum), gets iterated one character at a time and fails before any request with:

ValueError: 'M' is not a valid UserGroupAuditEventType

This wraps a single string in a list, the same way _to_event_types and _to_ids in schema/performance.py already handle a single value. Lists behave exactly as before. The types docstring on get_audit_events now says a single type is accepted.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

All Submissions

  • Have you followed the guidelines in our Contributing document?
  • Have you provided a description?
  • Are your changes properly formatted?

Changes to Core Features

  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?
  • Have you updated any code comments, as applicable?

Testing: added test_accepts_a_single_type (string and enum member) to tests/unit/schema/test_user_group_members_audit.py; both cases fail on develop and pass with this change. pytest tests/unit passes (502), ruff format --check is clean, and mypy reports no issues in user_group_audit.py.


Note

Low Risk
Localized SDK filter normalization with no auth or data-path changes; behavior for list inputs is unchanged.

Overview
Fixes a bug where passing one event type to UserGroup.audit_events / get_user_group_audit_events (e.g. types="MEMBER_ADDED" or a UserGroupAuditEventType member) was treated as an iterable of characters and failed with ValueError before any API call.

get_user_group_audit_events now wraps a lone str in a list before building the GraphQL where.types filter; lists of types behave as before. The types docstring on UserGroup.get_audit_events documents that a single type is allowed. Unit coverage adds test_accepts_a_single_type for string and enum inputs.

Reviewed by Cursor Bugbot for commit deb04be. Bugbot is set up for automated code reviews on this repo. Configure here.

types="MEMBER_ADDED" or types=UserGroupAuditEventType.MEMBER_ADDED was
iterated one character at a time and failed with "'M' is not a valid
UserGroupAuditEventType". Wrap a single string in a list, as the
performance helpers already do for their types filter.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant