charm and bundle _representation can contain unsupported keys

Bug #1215970 reported by Curtis Hovey
4
This bug affects 1 person
Affects Status Importance Assigned to Milestone
charmworld
Triaged
High
Unassigned

Bug Description

There are several places in the code where data is cast as a Charm or Bundle to normalise the data. eg
     bundle_data = Bundle(data)._representation
There are a few problems with this pattern. The caller knows about the private member. The caller assumes that _representation is sane -- it might contain unsupported keys. The caller can mutate the dict which will change the bundle or charm object.

The __init__ methods of Bundle and Charm could limit the update the _representation to keys that are supported.
A property like @representation or __iter__ could return a copy of the dict to ensure only sane and normalised key-values are returned that cannot mutate the object.

This pattern is common and methods do not now if the dict they are working with is a _representation. We may have code mutating objects and we do not understand the repercussions.

Tags: tech-debt
Curtis Hovey (sinzui)
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.