sartography / spiff-arena

SpiffWorkflow is a software development platform for building, running, and monitoring executable diagrams
https://www.spiffworkflow.org/
GNU Lesser General Public License v2.1
44 stars 34 forks source link

Can't read the task data under a Data Object #1485

Open sashayar13 opened 2 weeks ago

sashayar13 commented 2 weeks ago

Image

https://dev.app.spiff.status.im/process-models/misc:approval-strategy-main:notifications

jasquat commented 2 weeks ago

@sashayar13 do you have a process instance that this happened on? The 2 I can find on dev are errored - https://dev.app.spiff.status.im/process-instances/all?report_hash=da13a6cf36fcc372023f23dba5d2ce294dbedcf9c9369bbc85fa3eb74d88be13.

sashayar13 commented 2 weeks ago

@jasquat you can check https://dev.app.spiff.status.im/i/6682 Just dive into the Notify Finance sub-process -> Send Waku Notifications Call Activity

jasquat commented 2 weeks ago

Ah so can a view any data objects in any call activity?

I'm getting:

{
    "error_code": "bpmn_process_not_found",
    "message": "Cannot find a bpmn process with guid '95a7cd7d-7876-4e83-bc39-124aa72ebd36' for process instance 6682",
    "status_code": 404
}

on the call: https://dev.app.spiff.status.im/api/v1.0/process-data/default/misc:data-sync:bbhr-data-sync:orgstructure-bbhr-iplicit/resp_SendWakuMessage/6682?process_identifier=Waku_Messages&bpmn_process_guid=95a7cd7d-7876-4e83-bc39-124aa72ebd36

TO FIX: We need to load completed subprocesses on this call.

madhurrya commented 1 week ago

Tested in dev.app using https://dev.app.spiff.status.im/process-models/misc:qa:bpmn-model-testing:unit-test-call-activity-with-data-object and pp1 - send waku notification and now can see the task data in the data object.

madhurrya commented 1 week ago

But noticing an error with these models. When trying to access a data object inside a sub process.

https://dev.app.spiff.status.im/process-models/misc:qa:bpmn-model-testing:unit-test-sub-process-with-data-object https://dev.app.spiff.status.im/process-models/misc:qa:bpmn-model-testing:unit-test-expanded-sub-process-with-data-object

image

jasquat commented 1 week ago

I'm not sure what to do about this. Since the data object is set in the parent parent but gets used in the subprocess, the database only has the data object mentioned for the parent's process data.

@essweine what does spiff do when it passes data objects from a parent process to a subprocess? It's not stored in the database as apart of the subprocess process data. Is it ever apart of the subprocess data?

essweine commented 1 week ago

The data object is stored in the outermost workflow in which the data object is defined (so in this case the top level process). When retrieving a data object, the workflow where the reference is defined (as opposed to where the data object itself is defined) is checked, and if a value is found, it's returned; otherwise the parent is checked, and it goes up the stack of ancestor workflows until it's found.

An empty dict should get returned if there are no data objects defined: https://github.com/sartography/SpiffWorkflow/blob/651ed6c31d1e972b28f7c14f468d8e4c1b8cbcaa/SpiffWorkflow/bpmn/util/subworkflow.py#L31

This line from the backend may be causing that error: https://github.com/sartography/spiff-arena/blob/ea502a9868afdf9b03ae661715aa34acf716b35d/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py#L159

The sentry trace would show the actual line were the error occurs, but it's not readily accessible and I didn't get an error when I tried to run it though. But the fix would just be simple once the line was found.

jasquat commented 1 week ago

Thanks @essweine. Yeah that's the line. I'm trying to figure out what to do about it. If a user clicks on the data object on the process instance show page, is it fine to only return an empty hash rather than the value? We could try to cycle through parent processes until we find the data object.

essweine commented 1 week ago

I misunderstood the question. You could look at the data input associations on the task and use the data object get method to find it (this assumes that all the ancestor workflows are present, but I think that's the case?). Though I guess that means finding the tasks that have them,

But if you're just showing a list of all of them, you could just check all the subworkflows for the keys. They'll only exist in one place.

madhurrya commented 1 day ago

Sub process issue is also fixed now. Tested in test.app