ECMA script won't save or run

OH 3.1.0M4 on a CentOS8 system.

I’m trying to add an action to send a couple telegram messages in an ECMA Script. I’m copying this from a working rule and making some minor changes. After putting in the code and clicking on Save everything seems fine. I click on the “Run Now” at the bottom and the messages get sent. Then I click on Back to get to the main rule and it’s showing me:

Status:
UNINITIALIZED
HANDLER_INITIALIZING_ERROR
Getting handler 'script.ScriptAction' for module '1' failed: Config parameter 
'script' is missing in the configuration of module '1'. 

Looking at the Code tab all the commands I put in are now gone.

The commands:

var telegramActionMe = actions.get("telegram", "telegram:telegramBot:bot")
telegramActionMe.sendTelegram("Something happened. Image to follow...")
telegramActionMe.sendTelegramPhoto("http://camera03/snapshot/view0.jpg","camera")

Can’t see any difference between this and a similar rule that is working. When it fails I don’t see anything pop up in the logs beyond:
Failed to execute rule ‘Example_Rule' with status 'UNINITIALIZED'

It is almost always worth the effort to sit back and consider if there is a way to avoid duplicating code like this. It’s usually better in the long run to avoid duplicate code where possible.

Did you hit crtl-s or save at any point during your edits?

I hit the Save link multiple times. It may have been a temporary problem. I rebooted the system and tried again and ran into the same problem but a second attempt to define the rule from scratch and it worked. Pretty sure I did the steps in identical fashion and sequence so I’m not sure where it went right versus where it was going wrong.

If the problem persists, gather some logs and come back. There might be a weird bug or something related to saving.

1 Like

FYI: I encountered the same error. Turned out I was running a script while it was disabled. Apparently that is possible (OH 3.3.0).