Author Topic: bug in cloning function for workflows  (Read 211 times)

Online pls90

  • Sr. Member
  • ****
  • Posts: 282
  • Karma: +1/-0
bug in cloning function for workflows
« on: December 02, 2017, 07:04:03 am »
I have been using the cloning function quite a bit.
I think I found a bug which I can reproduce.

I was cloning my notification workflow which informs me when a door/window is open for a while.
When cloning the workflow you have the possibility to exchange the devices that are watched in a transition.
When I replace the device for the door/window to be watched with a new device all the transitions seem to be correctly edited in the cloned workflow.

The issue is, that those edited transitions will never fire.
Opening the workflow and resetting it will cause the transition to fire, but only once.
The next time the transition should fire again, it wont until you reset the workflow.

The only remedy for the issue is deleting the transition and setting it up again from scratch.
After that the workflow will work as expected.

The issue must have been introduced with one of the latest releases as I am quite positive it was working in it's initial release.

amg, you can easily reproduce the issue with a mini workflow that just changes states watching the status of a single device (e.g. switch on/off).

Offline amg0

  • Moderator
  • Sr. Hero Member
  • *****
  • Posts: 2714
  • Karma: +163/-8
Re: bug in cloning function for workflows
« Reply #1 on: December 02, 2017, 09:28:46 am »
once you perform the device change, make sure you save the workflow and reset. even better to a luup reload to be sure

I cannot reproduce, I have a simple workflow on a lamp , I clone it and change with another lamp. I save workflow and reload luup,   after the reload the 2 workflows are indeed working fine  with their own different lamps.

once you tried the clone then save / reload procedure,  maybe enable debug mode on ALTUI and redo the procedure,  then share the logs

Online pls90

  • Sr. Member
  • ****
  • Posts: 282
  • Karma: +1/-0
Re: bug in cloning function for workflows
« Reply #2 on: December 02, 2017, 12:40:36 pm »
I spent some time on this to find out what's going on.
Sometime cloning seems to work, sometime it doesn't.
What I mean by that is that transitions do not get evaluated as true although they should.

Here're some examples:
Workflow 111 watches over device 10106 (dining door).
I opened the door at 18:14:41, the transition did not take place.

Workflow 109 watches device 10107 (living door).
I opened the door at 18:15:01, the transition did not take place.

I captured a bit of log (please find attached). All that I can make of it is that there seem to occur errors around the times the door sensors were tripped:
Code: [Select]
2017-12-02 18:14:43.373   openLuup.context_switch::  ERROR: [string "[3] I_ALTUI.xml"]:1218: attempt to index field '?' (a nil value)
Code: [Select]
2017-12-02 18:15:04.488   openLuup.context_switch::  ERROR: [string "[3] I_ALTUI.xml"]:1218: attempt to index field '?' (a nil value)
« Last Edit: December 03, 2017, 02:34:35 am by pls90 »

Offline amg0

  • Moderator
  • Sr. Hero Member
  • *****
  • Posts: 2714
  • Karma: +163/-8
Re: bug in cloning function for workflows
« Reply #3 on: December 02, 2017, 05:37:47 pm »
I spent some time on this to find out what's going on.
Sometime cloning seems to work, sometime it doesn't.
What I mean by that is that transitions do not get evaluated as true although they should.

Here're some examples:
Workflow 111 watches over device 10106 (dining door).
I opened the door at 18:14:41, the transition did not take place.

Workflow 109 watches device 10107 (living door).
I opened the door at 18:15:01, the transition did not take place.

I captured a bit of log (please find attached). All that I can make of it is that there seem to occur errors around the times the door sensors were tripped:
Code: [Select]
2017-12-02 18:14:43.373   openLuup.context_switch::  ERROR: [string "[3] I_ALTUI.xml"]:1218: attempt to index field '?' (a nil value)
Code: [Select]
2017-12-02 18:15:04.488   openLuup.context_switch::  ERROR: [string "[3] I_ALTUI.xml"]:1218: attempt to index field '?' (a nil value)

log file is empty

Online pls90

  • Sr. Member
  • ****
  • Posts: 282
  • Karma: +1/-0
Re: bug in cloning function for workflows
« Reply #4 on: December 03, 2017, 02:35:12 am »
sorry, uploaded log again

Offline amg0

  • Moderator
  • Sr. Hero Member
  • *****
  • Posts: 2714
  • Karma: +163/-8
Re: bug in cloning function for workflows
« Reply #5 on: December 03, 2017, 01:54:01 pm »
ok, the log is not conclusive as I do not have the initialization of ALTUI in it. please try with this LUA file.

enable DEBUG mode
reload luup
try your workflows/transitions
give the whole log file so  I can see ALTUI in it

for what I can see it looks like it is trying to evaluate the worfklow 0-29 and 0-109 but fails to find it

Online pls90

  • Sr. Member
  • ****
  • Posts: 282
  • Karma: +1/-0
Re: bug in cloning function for workflows
« Reply #6 on: December 15, 2017, 04:08:47 pm »
Thank you amg, I was very busy but will now find the time to look into this.
I'll report back.

Online pls90

  • Sr. Member
  • ****
  • Posts: 282
  • Karma: +1/-0
Re: bug in cloning function for workflows
« Reply #7 on: December 15, 2017, 04:29:30 pm »
That went well. Loading openLuup / AltUI > No handler for data_request?id=lr_ALTUI_Handler
I rebooted the pi openLuup is running on, some error.
Logs attached.

Offline amg0

  • Moderator
  • Sr. Hero Member
  • *****
  • Posts: 2714
  • Karma: +163/-8
Re: bug in cloning function for workflows
« Reply #8 on: December 15, 2017, 04:40:38 pm »
Try with latest version on Github,  it will have the same issue I suppose but at least I will be able to try to see the proper source code lines
it looks like a corrupted workflow data structure

Online pls90

  • Sr. Member
  • ****
  • Posts: 282
  • Karma: +1/-0
Re: bug in cloning function for workflows
« Reply #9 on: December 15, 2017, 05:42:13 pm »
I did a fresh install, that brought back AltUI. As soon as I exchange the user_data.json to my latest file it get the "no handler".
It was running fine earlier, the only thing I did was disabling one workflow. That must have corrupted the json.
Is there a chance to remove the corrupted part or would I have to fallback to an older version of my user_data.json?
You mentioned source code lines. What should I do next to provide you with more input?

Offline amg0

  • Moderator
  • Sr. Hero Member
  • *****
  • Posts: 2714
  • Karma: +163/-8
Re: bug in cloning function for workflows
« Reply #10 on: December 15, 2017, 05:56:12 pm »
The best is to use latest github version, the. The log you gave are good although you need to put altui in debug mode first, then force a reload
If it is a corrupted workflow in user data then try to re enable workflows one by one until  you find the culprit

Online pls90

  • Sr. Member
  • ****
  • Posts: 282
  • Karma: +1/-0
Re: bug in cloning function for workflows
« Reply #11 on: December 15, 2017, 06:20:41 pm »
I did a lua5.1 openLuup_install.lua, that brought back AltUI.
So how do I exchange user_data.json to my file without running into the same no handler issue?

edit:
just thought about the backups I did as mentioned in ak's tips & tricks.
I have a backup.lzap file.
How can I restore that?
edit2
found it. This is actually very straightforward. Just do openLuup_reload with the filename of the backed up and compressed user_data as parameter.
So I am back in business. Now on to the initial problem.
« Last Edit: December 16, 2017, 05:12:08 am by pls90 »

Online pls90

  • Sr. Member
  • ****
  • Posts: 282
  • Karma: +1/-0
Re: bug in cloning function for workflows
« Reply #12 on: January 07, 2018, 12:03:36 pm »
I did some more testing on the latest version v2.09.2284.
I have not been able to reproduce the issues I had earlier.
So far everything I tried using the cloning function is working as expected.
I will try a bit more later next week.