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

Do not crash when calculating number of items in a list that has an invalid team task filter #1653

Merged

Conversation

caiosba
Copy link
Contributor

@caiosba caiosba commented Sep 14, 2023

Description

I noticed it happening on live only for duplicated workspaces. When a list has a team task filter that doesn't have a valid ID, an exception would happen. I was able to reproduce that exception in a unit test.

The fix was to discard the team task filter if the ID is blank.

Fixes CV2-3742.

How has this been tested?

TDD. I was able to implement a unit test that reproduced the issue.

Checklist

  • I have performed a self-review of my own code
  • I have added unit and feature tests, if the PR implements a new feature or otherwise would benefit from additional testing
  • I have added regression tests, if the PR fixes a bug
  • I have added logging, exception reporting, and custom tracing with any additional information required for debugging
  • I have commented my code in hard-to-understand areas, if any
  • I have made needed changes to the README
  • My changes generate no new warnings
  • If I added a third party module, I included a rationale for doing so and followed our current guidelines

…nvalid team task filter.

I noticed it happening on live only for duplicated workspaces. When a list has a team task filter that doesn't have a valid ID, an exception would happen. I was able to reproduce that exception in a unit test.

The fix was to discard the team task filter if the ID is blank.

Fixes CV2-3742.
@caiosba caiosba requested a review from melsawy as a code owner September 14, 2023 15:19
@@ -488,8 +488,8 @@ def file_filter

def team_tasks_conditions
conditions = []
return conditions unless @options.has_key?('team_tasks') && @options['team_tasks'].class.name == 'Array'
@options['team_tasks'].delete_if{ |tt| tt['response'].blank? }
return conditions unless @options['team_tasks'].class.name == 'Array'
Copy link
Contributor

Choose a reason for hiding this comment

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

why did you remove @options.has_key?('team_tasks') from unless condition?
I think we should keep it and only update delete_if to include tt['id'].blank?

Copy link
Contributor Author

@caiosba caiosba Sep 14, 2023

Choose a reason for hiding this comment

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

@melsawy because I think it's redundant with @options['team_tasks'].class.name ... if there is no team_tasks key, @options['team_tasks'].class.name is going to return NilClass

@caiosba caiosba requested a review from melsawy September 14, 2023 17:02
@codeclimate
Copy link

codeclimate bot commented Sep 14, 2023

Code Climate has analyzed commit 4a1b997 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (100% is the threshold).

This pull request will bring the total coverage in the repository to 99.7% (0.0% change).

View more on Code Climate.

@caiosba caiosba merged commit 982df0d into develop Sep 14, 2023
8 checks passed
@caiosba caiosba deleted the fix/CV2-3742-empty-team-task-filter-for-list-counter branch September 14, 2023 17:05
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.

2 participants