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

Skip seated user check for chat segment events #1500

Merged

Conversation

TamiTakamiya
Copy link
Contributor

Jira Issue: n/a

Description

Skip "seated user check" for Chat-related segment events because Chat is irrelevant to "seated users" or WCA.

I added two new entries to allow_list:

    "chatFeedbackEvent": {
        "*": None,
    },
    "chatOperationalEvent": {
        "*": None,
    },

The line "*": None, implies all properties are allows.

The problem was found on the chatOperationalEvent, but I have added a fix for the chatFeedbackEvent as well.

Testing

Steps to test

  1. Pull down the PR
  2. Run unit tests

Scenarios tested

Unit tests + manual tests by running local AI Connect server.

Production deployment

  • This code change is ready for production on its own
  • This code change requires the following considerations before going to production:

@TamiTakamiya TamiTakamiya marked this pull request as ready for review January 20, 2025 18:42
@@ -181,6 +181,10 @@ def redact_seated_users_data(event: Dict[str, Any], allow_list: Dict[str, Any])
Returns:
- dict: A new dictionary containing only the allowed nested keys from the source dictionary.
"""
# If an asterisk is found in the allow list, just return the given event dict to allow all keys.
if "*" in allow_list:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to have a test for these with your new check?

I know SonarCloud says you have 100%... but is that a false positive? I don't see any.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added two lines to test_operational_telemetry()`

        self.user.rh_user_has_seat = True
        self.user.organization = Organization.objects.get_or_create(id=1)[0]

which forces to run the test case with a "seated" user. Without this allow_list change, the test case failed. Isn't this change enough for the test coverage?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this change enough for the test coverage?

I found there were some test cases on redact operations in test_segment.py. I'll add two test cases to it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's fine @TamiTakamiya

It wasn't clear from your PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @TamiTakamiya, @manstis, sorry for late response, just my 2c the idea behind allow list agains block list in this case is making sure you are logging only something you really need to log, and avoid situation we are storing things we are not supposed to store.

Whit the asterisk it is easier to make a mistake and store unintended data.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hasys You're never late to the party and, as author of the original white listing, your opinion is important.. When you wrote the enhancement you no doubt had a clear vision in mind and it should not be bastardized to fit other use-cases (as this is how we end up with spaghetti code!)

What would you have proposed?

IIUC the issue was that the Chat Bot events were not recognised as "valid" events and hence filtered out.

@TamiTakamiya's change means they are no longer blocked by the filter and obviates the need to list all fields.

romartin
romartin previously approved these changes Jan 20, 2025
Copy link
Contributor

@romartin romartin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving although agree with @manstis , tests for new wildcard would be great, that's an important feature... Anyway I have tested same fix locally and that's the right fix. Thanks @TamiTakamiya !

manstis
manstis previously approved these changes Jan 20, 2025
Copy link
Contributor

@manstis manstis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation.

LGTM 👍

@@ -181,6 +181,10 @@ def redact_seated_users_data(event: Dict[str, Any], allow_list: Dict[str, Any])
Returns:
- dict: A new dictionary containing only the allowed nested keys from the source dictionary.
"""
# If an asterisk is found in the allow list, just return the given event dict to allow all keys.
if "*" in allow_list:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's fine @TamiTakamiya

It wasn't clear from your PR.

@TamiTakamiya TamiTakamiya dismissed stale reviews from manstis and romartin via ca7b364 January 20, 2025 19:53
@TamiTakamiya
Copy link
Contributor Author

@manstis @romartin I have added two simple test cases to test_segment.py. Pls re-review this. thanks!

Copy link
Contributor

@manstis manstis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@TamiTakamiya TamiTakamiya merged commit 5c1a119 into main Jan 20, 2025
11 checks passed
@TamiTakamiya TamiTakamiya deleted the TamiTakamiya/skip-seat-user-check-for-chat-segment-events branch January 20, 2025 20:50
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.

4 participants