Ampersand icon indicating copy to clipboard operation
Ampersand copied to clipboard

ExecEngine function parameter checking

Open RieksJ opened this issue 6 years ago • 8 comments

I ran the following code:

sessionReceptAanvraagForm :: SESSION * ReceptAanvraagForm [UNI]
ROLE ExecEngine MAINTAINS "Create a new ReceptAanvraagForm-form upon request"
RULE "Create a new ReceptAanvraagForm-form upon request": reqNewReceptAanvraagForm - sessionReceptAanvraagForm;sessionReceptAanvraagForm~ |- -I
VIOLATION (TXT "{EX} InsAtom;ReceptAanvraagForm;", SRC sessionReceptAanvraagForm
          ,TXT "{EX} InsPair;sessionReceptAanvraagForm;", SRC I, TXT ";ReceptAanvraagForm;_NEW"
          ,TXT "{EX} DelPair;reqNewReceptAanvraagForm;", SRC I, TXT ";ReceptAanvraagForm;_NEW"
          ,TXT "{EX} SetNavToOnCommit;/Recept_32_Aanvragen/_NEW"
          )

There are several flaws here:

  1. InsAtom does (usually) not take a second argument, but even if there is one (I recall that it might), a proper error message should be generated if this argument is NULL.
  2. _NEW must never be NULL, as it produces errors when subsequently used in InsPair etc.

These flaws are demonstrated in the error log:

[2018-06-21 07:35:10] RULE.DEBUG: Conjunct 'conj_6' broken: 1 violations [] []
[2018-06-21 07:35:10] EXECENGINE.INFO: {++ ExecEngine fixing 1 violations for rule 'Create a new ReceptAanvraagForm-form upon request' [] []
[2018-06-21 07:35:10] EXECENGINE.INFO: {+++ Fixing violation 1/1: (shhrfrgeeg8u6ka527akaauo53[SESSION],shhrfrgeeg8u6ka527akaauo53[SESSION]) [] []
[2018-06-21 07:35:10] DATABASE.DEBUG: SELECT DISTINCT "tgt" FROM (select distinct "SESSION" as src, "sessionReceptAanvraagForm" as tgt from "SESSION" where ("SESSION" is not null) and ("sessionReceptAanvraagForm" is not null)) AS "results" WHERE "src" = 'shhrfrgeeg8u6ka527akaauo53' AND "tgt" IS NOT NULL [] []
[2018-06-21 07:35:10] EXECENGINE.INFO: InsAtom(ReceptAanvraagForm,_NULL) [] []
[2018-06-21 07:35:10] DATABASE.DEBUG: SELECT "ReceptAanvraagForm" FROM "Form" WHERE "ReceptAanvraagForm" = '_NULL' [] []
[2018-06-21 07:35:10] CORE.DEBUG: Add atom _NULL[ReceptAanvraagForm] to plug [] []
[2018-06-21 07:35:10] TRANSACTION.DEBUG: Mark concept 'ReceptAanvraagForm' as affected concept [] []
[2018-06-21 07:35:10] DATABASE.DEBUG: INSERT INTO "Form" ("ReceptAanvraagForm", "Form") VALUES ('_NULL', '_NULL') ON DUPLICATE KEY UPDATE  "ReceptAanvraagForm" = '_NULL', "Form" = '_NULL' [] []
[2018-06-21 07:35:10] EXECENGINE.DEBUG: Atom '_NULL[ReceptAanvraagForm]' added [] []
[2018-06-21 07:35:10] EXECENGINE.INFO: InsPair(sessionReceptAanvraagForm,shhrfrgeeg8u6ka527akaauo53,ReceptAanvraagForm,_NEW) [] []
[2018-06-21 07:35:10] API.CRITICAL: Too few arguments to function {closure}(), 4 passed and exactly 5 expected [] []

I have the following requests:

  • Can we have more appropriate error messages for these situations, i.e. when _NEW is _NULL of some kind?
  • If InsAtom has an optional second argument, then please remove it. If for some reason someone uses it (which I can imagine), then we should have another function (e.g. InsNamedAtom) that takes 2 arguments. This way, every function can ensure it has exactly the right number of arguments, and situations such as InsAtom;Concept; will also produce a readable error message, which it currently dose not.

RieksJ avatar Jun 21 '18 05:06 RieksJ