Skip to content

AssignTickets empty check and test cases added #1438

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

Merged
merged 2 commits into from
Feb 7, 2022

Conversation

mridulji
Copy link
Contributor

@mridulji mridulji commented Feb 3, 2022

What this PR does / Why we need it: When making a call to AssignTicketsRequest, To check at least one of the AssignmentGroup have at least one ticket_ids present such that redis command doesn't throw error.

time="2020-10-09T12:38:09Z" level=error msg="failed to update assignments" app=openmatch component=app.backend error="ERR wrong number of arguments for 'mget' command"
time="2020-10-09T12:38:09Z" level=error msg="failed to update assignments for requested tickets" app=openmatch component=app.backend error="ERR wrong number of arguments for 'mget' command"

To prevent the code execution from going into this situation, we can check the length of the array containing all ticket_ids, so that in case AssignmentGroup doesn't contain any value in ticket_ids will return error codes.InvalidArgument

Which issue(s) this PR fixes: #1266

Closes #

Special notes for your reviewer:
unit test case condition added: TestUpdateAssignments

description: "empty ticketIds, error expected"
errMessage: "AssignmentGroupTicketIds is empty"

e2e test case added: TestAssignTicketsEmpty

Copy link
Contributor

@andrewgrundy andrewgrundy left a comment

Choose a reason for hiding this comment

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

looks good to me

@syntxerror syntxerror merged commit 2b73d52 into googleforgames:main Feb 7, 2022
@@ -255,6 +255,10 @@ func (rb *redisBackend) UpdateAssignments(ctx context.Context, req *pb.AssignTic
}
}

if len(idsI) == 0 {
return nil, nil, status.Error(codes.InvalidArgument, "AssignmentGroupTicketIds is empty")
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this test only going to match if all AssignmentGroups had empty TicketIds? It would be clearer if the message referred to that, as the closest I can see to AssignmentGroupTicketIds would be AssignmentGroup.TicketIds which would be an error appropriate for any AssignmentGroups having empty TicketIds.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

since variable idsI contains all TicketIds so this check will prevent from throwing error when there is not a single TicketIds is present and if any AssignmentGroups having empty TicketIds will be silently ignored.

@mridulji mridulji added this to the v1.4.0 milestone Mar 14, 2022
@mridulji mridulji added area/developer-experience This issue impacts developer experience when building a Matchmaker using Open Match area/refinement labels Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/developer-experience This issue impacts developer experience when building a Matchmaker using Open Match area/refinement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants