/srv/irclogs.ubuntu.com/2024/04/19/#launchpad-dev.txt

guruprasadcjwatson, I have run into what looks like a Storm bug/issue and want to talk to you about it before attempting to submit a fix. Do you have a few minutes to talk about it? Also, is there a better place for this discussion - I checked #storm but it is not present on irc.libera.chat.08:06
guruprasadThanks in advance for your time!08:06
cjwatsonguruprasad: Sure09:27
guruprasadWe have run into what looks like a bug in the JSONVariable class in Storm. In error scenario, the exception in https://bazaar.launchpad.net/~launchpad-committers/storm/lp/view/head:/storm/variables.py#L643 is hit because the value is already a dict instead of stringified JSON.09:31
guruprasadI happened to find https://git.launchpad.net/launchpad/tree/lib/lp/services/database/stormexpr.py#n307, the `_loads` method in particular, where you have mentioned that psycopg >= 2.5 already handles the conversion to JSON.09:32
guruprasadIn case of Launchpad, this happens when trying to set a JSON attribute (metadata_overrides) on IArchive via the webservice API and then using `archive.metadata_overrides` where `archive` is the model instance.09:33
guruprasadStrangely, this happens only in the case of 'do a web service call to set it and then check the model instance' and not the 'set it on the model instance and check it after that' operation09:34
cjwatsonguruprasad: It's not just that you need to use storm.databases.postgres.JSONVariable instead (assuming this is a jsonb column)?09:35
cjwatson(or .JSON)09:36
guruprasadAh!09:37
cjwatsonstorm.variables.JSONVariable / storm.properties.JSON is only for text columns that happen to contain JSON, not for the native pg types09:39
guruprasadThis is a jsonb column in postgres and the model uses storm.locals.JSON09:39
cjwatsonYeah, use the one in s.d.p instead and you should be fine09:39
cjwatsonMight be worth a docstring patch to storm though09:40
guruprasadI can make that change and submit it for review - what do you think the docstring should say and which one?09:41
cjwatsonprobably all the involved classes should have docstringa that say what kind of columns they're meant to be used with09:42
guruprasadSure. I will do that and propose the changes soon.09:44
guruprasadThanks for the help!09:44
cjwatsonI was 90% sure I knew what the problem was the moment I read "JSON", so that's a good sign it needs better docs :)09:52

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!