Picolab / pico-engine

An implementation of the pico-engine hosted on node.js
http://picolabs.io/
MIT License
43 stars 8 forks source link

Strangeness when using a defaction defined in a module #616

Open b1conrad opened 2 years ago

b1conrad commented 2 years ago

Set up a module that defines a defaction which references meta:eci and meta:rid

Using the defaction from a rule in a ruleset that uses the module.

Strange things:

  1. meta:eci is null in the defaction (did not test, but assume that meta:inEvent (and perhaps meta:inQuery also) is false)
  2. meta:rid is the RID of the module, and I was hoping for the RID of the using ruleset (vainly likely). However, when I used the wrong family channel, the error message shows that the RID of the using ruleset is available to the code! See stack trace:
    2022-09-22T20:48:07.423Z - EVENT cl8dilrqi00kw1gylbtaf32av testnotification:test {}
    20:48:07.423Z [DEBUG] txnQueued EVENT cl8dilrqi00kw1gylbtaf32av testnotification:test {}
    20:48:07.425Z [DEBUG] txnStart {}
    20:48:07.425Z [DEBUG] event added to schedule {"eci":"cl8dilrqi00kw1gylbtaf32av","domain":"testnotification","name":"test","data":{"attrs":{"_headers":{"host":"localhost:3000","connection":"keep-alive","content-length":"2","sec-ch-ua":"\"Google Chrome\";v=\"105\", \"Not)A;Brand\";v=\"8\", \"Chromium\";v=\"105\"","sec-ch-ua-mobile":"?0","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36","sec-ch-ua-platform":"\"macOS\"","content-type":"application/json; charset=utf-8","accept":"*/*","origin":"http://localhost:3000","sec-fetch-site":"same-origin","sec-fetch-mode":"cors","sec-fetch-dest":"empty","referer":"http://localhost:3000/","accept-encoding":"gzip, deflate, br","accept-language":"en-US,en;q=0.9,ko;q=0.8,fr;q=0.7,ig;q=0.6"}}},"time":1663879687422}
    20:48:07.426Z [DEBUG] rule selected testnotification : tester
    20:48:07.426Z [KLOG] rid "notification"
    20:48:07.426Z [KLOG] eci null
    20:48:07.428Z [ERROR] Error: This is a family channel and only the owner can use it. {"rid":"testnotification"}
    20:48:07.428Z [DEBUG] fired 
    20:48:07.428Z [DEBUG] txnDone {}