-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Relation data contents seems to support non-string keys, except it doesn't #785
Comments
@pengale @rwcarlsen I think the issue is that in Is this something that we want to address in a more generalized manner? @jameinel thoughts on this? |
From the ops standpoint, it seems like we should keep setting and getting symmetrically w.r.t. types. If we start auto-converting some types to str, then how will we know to auto-convert them from string when the user retrieves them? We can't. Because of this, I think it's best that we only explicitly take and provide strings. |
My point is that right now we are implicitly and silently converting everything to string. My proposal would be to be more strict and check beforehand that arg1 and arg2 are already strings (or a handful of primitive types we're convinced we can safely stringify without problems) |
@PietroPasotti I'm mostly in agreement - just that I don't think we should do any types other than string unless we have a way to know when to convert to non-string types upon retrieval (we currently don't). |
Ok, so I think we're totally in agreement: we should do assert isinstance(key, str)
assert isinstance(value, str) on each |
If I do
relation.data[self.unit]['foo'] = 42
, I get a nice ModelError telling me relation data values should be strings. Fair enough.If I do
relation.data[self.unit][42] = 'foo'
, I get no error, if I inspect the databag the value is there:assert relation.data[self.unit][42] == 'foo'
works allright.however, nothing is committed (I think?) and when the charm executes again, the data is gone.
This looks like a bug?
The text was updated successfully, but these errors were encountered: