pki-bot / pki-issues-final

0 stars 0 forks source link

UGSubsystem.findUsers() should not throw exception on empty result #908

Open pki-bot opened 4 years ago

pki-bot commented 4 years ago

This issue was migrated from Pagure Issue #914. Originally filed by edewata (@edewata) on 2014-03-14 22:21:11:


The UGSubsystem.findUsers() takes a filter and searches for all matching users. Currently it throws an exception if the search returns no matching users. See UGSubsystem.java:413-416:

// if v contains nothing, just throw exception
if (v.size() == 0) {
    throw new EUsrGrpException(CMS.getUserMessage("CMS_USRGRP_USER_NOT_FOUND"));
}

While throwing exception might be fine for certain methods, this is inappropriate for findUsers() since empty result is a valid result. For example, CLI or UI should show an empty result instead of an error message.

Also the no result exception is almost indistinguishable from other real errors because it's using the same EUsrGrpException class. For now the exception handler would have to compare the exception message in order to determine the appropriate action. Exception messages are meant to be read by human, they are not supposed to be used to determine program flow.

This issue may also exist in other search operations that return multiple results.

pki-bot commented 4 years ago

Comment from mharmsen (@mharmsen) at 2014-09-26 01:38:43

proposed Milestone: 10.2.3 - Per Dogtag 10.2.3 meeting of 09/25/2014

pki-bot commented 4 years ago

Comment from mharmsen (@mharmsen) at 2015-01-15 01:17:04

Per Dogtag 10.2.X meeting of 01/14/2015: Milestone 10.3

pki-bot commented 4 years ago

Comment from edewata (@edewata) at 2017-02-27 13:58:09

Metadata Update from @edewata: