-
Notifications
You must be signed in to change notification settings - Fork 24
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
Fix the wrong validator of ModulemdUnit.profiles [RHELDST-22116] #217
Conversation
Currently, the wrong validator resulted in a TypeError, saying pubtools-pulplib is validating the after-conversion "profiles" field as a dict: TypeError: "'profiles' must be <class 'dict'> (got frozendict.frozendict({'test': ['secondRepoRPM']}) that is a <class 'frozendict.frozendict'>)." The validator of ModulemdUnit.profiles should be a frozendict rather than a dict after the "converter=frozenlist_or_none_converter" conversion.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #217 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 47 47
Lines 3162 3162
=========================================
Hits 3162 3162 ☔ View full report in Codecov by Sentry. |
There seems to be a deeper story behind this issue. I find it hard to believe that the bug could be as described because it hasn't changed recently and how could it possibly not have broken anything until now? Furthermore, these validators are documented as using "isinstance", so when we say optional_dict we're not saying the value has to be precisely a dict. It's allowed to be any subclass of dict, and I would expect frozendict to be a subclass of dict, so it should have been working fine. Could you check the following in whatever environment you could reproduce this? For me, frozendict is an instance of dict so there is no problem with the validator.
|
...and I do have a vague recollection that |
@rohanpm Sure. And it approved your assumption that environment is the cause.
But it seems both cannot allow the subclass to be True. Here is a
Here is the
I will keep doing some investigation for frozendict subclass issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose we should still submit this despite that an issue outside of this library triggers the problem. It should work fine as long as we ensure that the converter and the validator are using the same type (i.e. either both using the pure-python frozendict or both using the C extension frozendict).
Currently, the wrong validator resulted in a TypeError, saying pubtools-pulplib is validating the after-conversion "profiles" field as a dict:
TypeError: "'profiles' must be <class 'dict'>
(got frozendict.frozendict({'test': ['secondRepoRPM']}) that is a <class 'frozendict.frozendict'>)."
The validator of ModulemdUnit.profiles should be a frozendict rather than a dict after the "converter=frozenlist_or_none_converter" conversion.