Same workflow added to two different programs

workflow
programs
Tags: #<Tag:0x00007fbae1cca738> #<Tag:0x00007fbae1cca5a8>

(Dimitri R) #1

Hi all,

While I was working with @ridmal on extending Initializer to handle programs, workflows and states I came across something weird.

In one of our tests we ended up adding the same workflow to two different programs (see here). This makes sense in the real world by the way, but our data model doesn’t quite support that situation adequately.

More specifically the issue is that ProgramWorkflow.getProgram() returns a single value (here). And it happens to be the last program to which the workflow was added.

Any clues?

Cc @burke @darius @mseaton @dkayiwa


(Mark Goodrich) #2

I believe the general pattern is that a workflow is only valid for a single program… if you need the exact same workflow for two programs, it still needs up as two discreet workflows (though the workflows and states could link to the same concepts).

Not sure if there’s a strong reason to change that model?

Take care, Mark


(Dimitri R) #3

Thanks @mogoodrich, that makes sense. However it turns out that Core doesn’t prevent to do it via the API, leading to an unstable behaviour of ProgramWorkflow.getProgram(). Do we agree that a validation should be added, or am I missing something?

For the time being we will prevent this use case through Initializer.


(Dimitri R) #4

In Iniz I have explicitly taken care of that here.


(Mark Goodrich) #5

Thanks @mksd… would be worth confirming with others that my assumption above is correct (@burke @darius @mseaton), and, yes, if so, I would assume that we should add validation to prevent this.

Take care, Mark


(Mike Seaton) #6

What exactly would the validation do? As you say, ProgramWorkflow has a single Program property, and the program_workflow table has a program_id column. So there should be no confusion around whether or not a workflow can be associated with multiple programs.

All of the code is not included above, but it’s possible that those 2 programs do not actually contain the same workflow. Rather they might contain different workflows that were accidentally given the same uuid. I believe the “equals” method simply looks at matching uuids to determine equality.

Mike