Skip to content

compound_parameter_present() does not report the expected type #155

@ktdreyer

Description

@ktdreyer

When a user specifies the wrong type and we catch that in compound_parameter_present(), we raise a ValueError with a human-readable message about the parameter, the type we expected to find, and the that we found.

When we raise the ValueError, the message about the type we expected to find is not correct.

I uncovered this because I accidentally passed a bare string into the inheritance parameter for koji_tag. We expect a "list" here, rather than a "str". Here is the error message I got:

ValueError: inheritance must be a type, not a str

Here is the error message I expected:

ValueError: inheritance must be a list, not a str

This diff works:

--- a/library/koji_tag.py
+++ b/library/koji_tag.py
@@ -431,7 +435,7 @@ def compound_parameter_present(param_name, param, expected_type):
     if param not in (None, ''):
         if not isinstance(param, expected_type):
             raise ValueError(param_name + ' must be a '
-                             + expected_type.__class__.__name__
+                             + expected_type.__name__
                              + ', not a ' + param.__class__.__name__)
         return True
     return False

We need to add a unit test for this method, because the unit tests do not cover it currently.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions