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

modulemd_defaults.profiles is mutable #88

Open
rohanpm opened this issue May 1, 2020 · 0 comments
Open

modulemd_defaults.profiles is mutable #88

rohanpm opened this issue May 1, 2020 · 0 comments

Comments

@rohanpm
Copy link
Member

rohanpm commented May 1, 2020

Summary

modulemd_defaults.profiles is declared as a dict, which is a mutable type. This is bad as it makes instances of ModulemdDefaultsUnit dangerous to hash or to use from threads.

It is a goal that the model classes are immutable wherever possible. For list fields, we achieved that by using frozen lists. Similarly, if we have dicts, those should be frozen dicts to keep instances immutable.

Issue Type

  • Bug Report

Steps to reproduce

  • Create a ModulemdDefaultsUnit with profiles={}
  • Change the contents of profiles

Actual results

Changing contents of profiles is possible. If the ModulemdDefaultsUnit was used in a set or as a dict key, bad things happen.

Expected results

Attempting to change contents of profiles causes an exception to be raised.

Additional Information

I think the best solution to this would be for 'profiles' not to be a raw dict at all but some properly modelled type, similarly as done for MaintenanceEntry, but I note this wouldn't be backwards-compatible. Profiles being a raw dict means one can't be confident the dict has the right structure or that it's not being abused.

@dichn dichn pinned this issue Feb 22, 2022
@dichn dichn unpinned this issue Feb 22, 2022
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

No branches or pull requests

1 participant