zooniverse / panoptes

Zooniverse API to support user defined volunteer research projects
Apache License 2.0
103 stars 41 forks source link

Project Builder: Workflow Steps cannot be updated #3960

Closed shaunanoordin closed 2 years ago

shaunanoordin commented 2 years ago

API issue?

Recorded on 6 Oct 23:00 BST Affects: FEM WFs with Transcription Tasks, possibly others

When the Project Builder attempts to send an update to the API, to change a Workflow's Steps, the data isn't fully digested (possibly by the API?). As a result, any Workflow that uses Steps (mostly WFs with Transcription Tasks) stop working.

For example, if I send...

PUT /api/workflows/3631

body: {
  workflows: {
    steps: [[ "S0", { "taskKeys": [ "T0", "T1" ] } ]]
  }
}

...the API will return...

workflow: {
  steps: [[ "S0", {} ]]
}

Original Report

@snblickhan reported on Slack that a Transcription WF on Corresponding with Quakers was crashing.

This WF 22387 was copied (via Project Builder's "Copy Workflow" function) from WF 22208.

@mcbouslog determined that the problem was due to 22208 having "incomplete steps". (i.e. you have step keys S1, but empty {} step values)

Replication

Example:

On a newly-created Workflow, I create a Transcription Task, generating a PUT request.

Screenshot 2022-10-06 at 23 00 23 Screenshot 2022-10-06 at 22 59 52

The API, however, responds with steps that's missing data

Screenshot 2022-10-06 at 23 00 09

Status

This is an urgent issue for any project FEM project with Transcription Tasks.

Impact:

Possible workaround:

camallen commented 2 years ago

Looks like this is an underlying framework issue fixed in 5.2+ and we need to backport it to support this nested array form.

https://github.com/rails/rails/pull/32593/files that landed in https://github.com/rails/rails/blob/v5.2.8.1/actionpack/CHANGELOG.md#rails-521-august-07-2018

I'll look at backporting this fix for rails < 5.2

The issue is the payload structure of nested arrarys with json objects.

FWIW - i find the steps payload data structure somewhat strange, why is it an array of arrays instead of say a keyed json object? I'm most likely naive about what this data structure is trying to achieve but i think this would have worked without issue

# payload that doesn't work
[[ "S0", { "taskKeys": [ "T0", "T1" ] } ]]

# payload that should work where the step identifier links the task steps...
{ "S0": [{ "taskKeys": [ "T0", "T1" ] }] }