CGRU / cgru

CGRU - AFANASY
http://cgru.info/
GNU Lesser General Public License v3.0
278 stars 111 forks source link

Jobs with json in custom_data are invalid on server restart #574

Closed lithorus closed 1 year ago

lithorus commented 1 year ago

When a job is created with json in the custom_data property the job is discarded by the server.

This is due to the job data on disk is also encoded as json and the custom_data is not escaped.

Code to reproduce it :

import json

import af

job = af.Job("Job with custom data block")

block = af.Block("block with custom data")
task = af.Task("test")
task.setCommand("echo 0")
block.tasks.append(task)
custom_data = {"test": "a"}
block.data['custom_data'] = json.dumps(custom_data)

job.blocks.append(block)
job.send()
sebastianelsner commented 1 year ago

Strange. I use the newest version and have lots of custom data... and this is not happening....

timurhai commented 1 year ago

Any af::Node has custom data and it is escaped on writing: https://github.com/CGRU/cgru/blob/master/afanasy/src/libafanasy/afnode.cpp#L108 But af::BlockData is not af::Node it was not. May be you are using custom data on Nodes only (User, Job, Render,...).

sebastianelsner commented 1 year ago

Ah! I am using it on the job. Did not know its possible on the block! Nice!