nextgenhealthcare / connect

The swiss army knife of healthcare integration.
Other
914 stars 275 forks source link

Invalid code templates are allowed to be imported in the CLI and via restoring a server config #2939

Closed rbeckman-nextgen closed 4 years ago

rbeckman-nextgen commented 4 years ago

The client won't allow you save code templates that have syntax errors. However you can still get invalid templates in a saved state by importing them through the CLI or through restoring a server config. When this happens, no channels will be able to deploy until the syntax error is resolved.

Imported Issue. Original Details: Jira Issue Key: MIRTH-3019 Reporter: narupley Created: 2013-10-18T13:51:57.000-0700

rbeckman-nextgen commented 4 years ago

Revision 7727: Code templates are now always checked for valid syntax on the server side before they are actually inserted or updated. With the improvements made in MIRTH-3762, the CLI will now also print out a table of code templates that failed to be imported.

Imported Comment. Original Details: Author: narupley Created: 2015-08-22T16:21:47.000-0700

rbeckman-nextgen commented 4 years ago

$codetemplate import /Users/minhtran/Desktop/MinhShare/inbox/invalidsyntax.xml ` 0 code templates imported successfully. The following code template failed to be imported:

Name        Id                                    Type                      Revision  Last Modified
----------  ------------------------------------  ------------------------  --------  -------------------
Template 1  8dccd2c6-f11f-433b-9ae7-0231b80d18fe  Function                  1         2015-08-27 13:41:21

com.mirth.connect.client.core.ClientException: com.mirth.connect.client.core.ClientException: method failed: HTTP/1.1 500 Unable to save code template "Template 1": Error on line 10: missing ; before statement (e2ab71a4-59db-459c-88ef-7d7632d9d271#10). at com.mirth.connect.client.core.ServerConnection.executePostMethod(ServerConnection.java:140) at com.mirth.connect.client.core.Client.updateCodeTemplate(Client.java:592) at com.mirth.connect.cli.CommandLineInterface.commandImportCodeTemplates(CommandLineInterface.java:1115) at com.mirth.connect.cli.CommandLineInterface.executeStatement(CommandLineInterface.java:409) at com.mirth.connect.cli.CommandLineInterface.runConsole(CommandLineInterface.java:230) at com.mirth.connect.cli.CommandLineInterface.runShell(CommandLineInterface.java:195) at com.mirth.connect.cli.CommandLineInterface.run(CommandLineInterface.java:161) at com.mirth.connect.cli.CommandLineInterface.(CommandLineInterface.java:103) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at com.mirth.connect.cli.launcher.CommandLineLauncher.main(CommandLineLauncher.java:53) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.exe4j.runtime.LauncherEngine.launch(Unknown Source) at com.install4j.runtime.launcher.Launcher.main(Unknown Source) Caused by: com.mirth.connect.client.core.ClientException: method failed: HTTP/1.1 500 Unable to save code template "Template 1": Error on line 10: missing ; before statement (e2ab71a4-59db-459c-88ef-7d7632d9d271#10). at com.mirth.connect.client.core.ServerConnection.getResponsePayload(ServerConnection.java:368) at com.mirth.connect.client.core.ServerConnection.executePostMethod(ServerConnection.java:135) ... 18 more `

Imported Comment. Original Details: Author: minht Created: 2015-08-27T13:47:39.000-0700

rbeckman-nextgen commented 4 years ago

Server(s) and URLs Used: Run Mirth Connect on local OSX Yosemite 10.10 Version(s)/Build(s) to verify new feature: mirthconnect-3.3.0.7736.b1707-unix How Tested (list tests run): Test1 - save code template with invalid syntax

Test2 - using CLI import code template with invalid syntax

Test3 - restore config with invalid code template

Verified Fixed: Test1 & 2: Mirth Connect prevents Save or Import invalid syntax accordingly {color:red}Test3: Eventhough restore config threw an error exception, it still restored all channels and empty code template libraries. Server.log flushed with "java.lang.NullPointerException" {color}

Additional Info: Test4 - restore config with valid code template

Imported Comment. Original Details: Author: minht Created: 2015-08-27T14:04:27.000-0700

rbeckman-nextgen commented 4 years ago

Java Exception from Restore Config with Code Template Libraries ` [2015-08-27 14:26:44,916] ERROR (com.mirth.connect.server.controllers.Cache:130): Error refreshing Code Template Library cache java.lang.NullPointerException

ERROR 2015-08-27 14:26:29,717 [qtp771744259-44] com.mirth.connect.server.controllers.Cache: Error refreshing Code Template Library cache java.lang.NullPointerException at com.mirth.connect.server.controllers.Cache.refreshCache(Cache.java:99) at com.mirth.connect.server.controllers.Cache.getAllItems(Cache.java:48) at com.mirth.connect.server.controllers.DefaultCodeTemplateController.getLibraries(DefaultCodeTemplateController.java:71) at com.mirth.connect.server.builders.JavaScriptBuilder.appendCodeTemplates(JavaScriptBuilder.java:454) at com.mirth.connect.server.builders.JavaScriptBuilder.generateScript(JavaScriptBuilder.java:102) at com.mirth.connect.server.util.javascript.JavaScriptUtil.compileAndAddScript(JavaScriptUtil.java:640) at com.mirth.connect.server.util.javascript.JavaScriptUtil.compileAndAddScript(JavaScriptUtil.java:619) at com.mirth.connect.server.util.javascript.JavaScriptUtil.compileAndAddScript(JavaScriptUtil.java:615) at com.mirth.connect.server.util.javascript.JavaScriptUtil.compileGlobalScripts(JavaScriptUtil.java:599) at com.mirth.connect.server.controllers.DefaultScriptController.compileGlobalScripts(DefaultScriptController.java:125) at com.mirth.connect.server.controllers.DefaultCodeTemplateController.updateCodeTemplate(DefaultCodeTemplateController.java:437) at com.mirth.connect.server.controllers.DefaultConfigurationController.setServerConfiguration(DefaultConfigurationController.java:607) at com.mirth.connect.server.servlets.ConfigurationServlet.doPost(ConfigurationServlet.java:159) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:652) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:447) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:225) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1038) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:374) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:189) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:972) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135) at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) at org.eclipse.jetty.server.Server.handle(Server.java:363) at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:483) at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:931) at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:992) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:856) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82) at org.eclipse.jetty.io.nio.SslConnection.handle(SslConnection.java:196) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:627) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:51) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) at java.lang.Thread.run(Thread.java:745) `

Imported Comment. Original Details: Author: minht Created: 2015-08-27T14:45:32.000-0700

rbeckman-nextgen commented 4 years ago

Restore config does not work properly with "Unassigned" Library

Imported Comment. Original Details: Author: minht Created: 2015-08-27T14:47:01.000-0700

rbeckman-nextgen commented 4 years ago

This should be fixed now with the latest changes, since the Unassigned library is gone. In testing you'll just need to make new exports, as any previously existing exports from earlier trunk builds may not work.

Imported Comment. Original Details: Author: narupley Created: 2015-08-29T19:08:02.000-0700

rbeckman-nextgen commented 4 years ago

Issue found /exists in Version(s)/Build(s): mirthconnect-3.3.0.7753.b1734-unix

What are the issues:

Imported Comment. Original Details: Author: minht Created: 2015-09-02T16:42:26.000-0700

rbeckman-nextgen commented 4 years ago

Attached test steps from Re-test with mirthconnect-3.3.0.7753.b1734-unix

Imported Comment. Original Details: Author: minht Created: 2015-09-02T16:43:58.000-0700

rbeckman-nextgen commented 4 years ago

Revision 7771: Fixed issues with the CLI due to the latest code templates changes. The export/remove operations now only allow a single code template (though they will allow multiple for the libraries option). When exporting/removing by name, it no longer acts as a search criterion, and instead will match the library / code template name exactly.

The server config restore thing is actually more general, so I've created a separate issue for it: MIRTH-3774

Imported Comment. Original Details: Author: narupley Created: 2015-09-04T13:10:37.000-0700

rbeckman-nextgen commented 4 years ago

Server(s) and URLs Used: Run Mirth Connect on local OSX Yosemite 10.10 Version(s)/Build(s) to verify fixes: mirthconnect-3.3.0.7773.b1758-unix How Tested (list tests run): Start Mirth Connect and CLI >mccommand $codetemplate export Template /Users/minhtran/Desktop/MinhShare/test.xml No code templates found for search criteria "Template". $codetemplate remove Template No code templates found for search criteria "Template". $codetemplate library remove Library No code template libraries found for search criteria "library". $codetemplate library remove "Library 1" Successfully removed 1 code template library $codetemplate export * /Users/minhtran/Desktop/MinhShare/CodeTemplate/MC330_codetemplate_export_all.xml No code templates found for search criteria "*". $codetemplate library export * /Users/minhtran/Desktop/MinhShare/CodeTemplate/MC330_codetemplate_export_allLibraries.xml Successfully exported 3 code template libraries. $codetemplate library remove "Library 1" Successfully removed 1 code template library.

Verified Fixes: For code template: export/remove operation only allow a single code template and not wild card "*". We can still use wild card to export/remove All Libraries CLI now requires the exact code template / library name. It does not treat name as search criteria as before.

Imported Comment. Original Details: Author: minht Created: 2015-09-04T15:13:00.000-0700

rbeckman-nextgen commented 4 years ago

Verified invalid code template being omitted during import See MIRTH-3774 for restore config

Imported Comment. Original Details: Author: minht Created: 2015-09-04T17:11:35.000-0700