Troubleshooting Corticon.js Studio problems
- Last Updated: May 3, 2021
- 3 minute read
- Corticon.js
- Documentation
When developing rules in Corticon.js Studio or deploying rules to production, you need strategies for preventing and resolving problems where rules are not producing the expected results. Considering these early in your project will help you establish best practices and prepare you for when a problem occurs. Corticon provides capabilities to help.
This section provides both best practice guidance and specific techniques to help you avoid and troubleshoot problems.
Break the project down into discrete, modular components
Corticon lets you create complex Ruleflows from smaller building blocks. When starting the development of a new rule project, create multiple simpler Rulesheets to satisfy a rules requirement rather than a single complex Rulesheet. Simple Rulesheets will be easier to validate. Create multiple small Ruleflows and assemble them into a larger Ruleflow using nested Ruleflows. Small Ruleflows are similarly easier to validate. Creating a complex Ruleflow from already validated small building blocks will minimize the chance of problems.
Use the Rulesheet logical analysis functions
Corticon provides logical analysis functions to identify gaps and conflicts in your Rulesheets. Utilizing these during rule development will minimize the chance of run time anomalies.
Create Ruletests for individual Rulesheets and Ruleflows
Creating Ruletests for each Rulesheet and Ruleflow will provide a means to unit test, or validate, each. Knowing that each of these building blocks has been well tested will give you greater confidence you will not see problems when assembling them into Ruleflows.
When modifying a rule project, run existing Ruletests
Running Ruletests will help ensure you do not introduce unintended changes in the behavior of Rulesheets or Ruleflows.
Troubleshoot rules in Ruletests
Utilize debug logging if your rules are not working as expected.
To enable debug logging in Corticon.js Studio, edit your brms.properties file and add the line:
loglevel=DEBUG
The log will detail the execution of your rules when you run Ruletests so that you can better understand the execution of your rules and identify anomalies causing incorrect results.
Restart Studio and the new log level will be used when you run Ruletests. The
log information will be written to the file CcStudio.log in your log
folder of the [CORTICON_WORK] directory specified during install.
Debug Logging in Deployed Rules
To enable debug logging when deploying rules, you need to set the
logLevel to 1 in the JSON configuration object passed to your rules
when executed from your JavaScript application.
const configuration = { logLevel: 1};
result = decisionService.execute(payload, configuration)
See the generated wrapper code produced by Corticon.js Studio when packaging rules for deployment to various supported platforms.
Debugging JavaScript Platforms Differences
Corticon.js supports rule deployment to any platform with a compatible version of JavaScript. In principal, Corticon rules should execute identically. When you encounter a problem where rules are executing differently, you should perform the following tests:
- Execute rules in the Corticon.js Studio tester: Corticon.js Studio runs rules for the tester by deploying them behind the scenes to an instance of Node.js and executing them with the input payload specified in the Testsheet. If your rules don’t execute correctly, there is either a problem in your rules or a bug in Corticon.js.
- Execute rules in a browser: Corticonj.js Studio
provides the option to package rules for browser deployment. As part of this
Corticon.js produces a simple HTML file,
browser.sample.html, for testing rules in a browser that presents a simple form where you can provide an input JSON payload, pass it to your rules, and then see the results.If your rules execute correctly in the Corticon.js Studio tester but not correctly in the browser, there is a difference in behavior of the underlying JavaScript engine and you should contact Corticon support.
- Execute rules on your target platform: Your rules might execute correctly in both in the Corticon.js Studio tester and in a browser, but behave differently on your target platform. There might be an incompatibility in the JavaScript engine on your platform or some platform specific environment issues are interfering with rule execution; for example, insufficient memory. You could contact Corticon support but if it is a problem unique to your platform, their options for assistance will be limited.
Preparing to Call Support
When you need to contact Progress support for assistance with Corticon.js rule execution errors, be prepared to provide any related debug logs, as well as your rule assets and a sample JSON payload demonstrating the incorrect behavior.