XPages jsonRpcService error message verbosity - xpages

I have a JSON-RPC service defined in an XPages application using the <xe:jsonRpcService> tag.
If a request to this server causes a JSON parsing error, a verbose error message is returned, example:
{
"code": 400,
"text": "Bad Request",
"message": "Error when parsing JSON stream",
"type": "text",
"data": "com.ibm.domino.services.ServiceException: \r\n\tat com.ibm.domino.services.rpc.RpcServiceEngine.renderService(RpcServiceEngine.java:82)\r\n\tat com.ibm.domino.services.HttpServiceEngine.processRequest(HttpServiceEngine.java:168)\r\n\tat com.ibm.xsp.extlib.component.rpc.UIJsonRpcService._processAjaxRequest(UIJsonRpcService.java:299)\r\n\tat com.ibm.xsp.extlib.component.rpc.UIJsonRpcService.processAjaxRequest(UIJsonRpcService.java:282)\r\n\tat com.ibm.xsp.util.AjaxUtilEx$1.invokeContextCallback(AjaxUtilEx.java:194)\r\n\tat javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:862)\r\n\tat javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:878)\r\n\tat javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:878)\r\n\tat javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:878)\r\n\tat javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:878)\r\n\tat com.ibm.xsp.component.UIViewRootEx.invokeOnComponent(UIViewRootEx.java:1552)\r\n\tat com.ibm.xsp.util.AjaxUtilEx.renderAjaxPartialLifecycle(AjaxUtilEx.java:188)\r\n\tat com.ibm.xsp.webapp.FacesServletEx.renderAjaxPartial(FacesServletEx.java:249)\r\n\tat com.ibm.xsp.webapp.FacesServletEx.serviceAjaxPartialView(FacesServletEx.java:200)\r\n\tat com.ibm.xsp.webapp.FacesServletEx.serviceAjaxPartialViewSync(FacesServletEx.java:176)\r\n\tat com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:155)\r\n\tat com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:159)\r\n\tat com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:138)\r\n\tat com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103)\r\n\tat com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:588)\r\n\tat com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1335)\r\n\tat com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:865)\r\n\tat com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:808)\r\n\tat com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:577)\r\n\tat com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1319)\r\n\tat com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:662)\r\n\tat com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:482)\r\n\tat com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:357)\r\n\tat com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:313)\r\n\tat com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)\r\nCaused by: com.ibm.commons.util.io.json.JsonException: Error when parsing JSON stream\r\n\tat com.ibm.commons.util.io.json.JsonParser.fromJson(JsonParser.java:86)\r\n\tat com.ibm.domino.services.rpc.RpcServiceEngine.renderService(RpcServiceEngine.java:55)\r\n\t... 29 more\r\nCaused by: com.ibm.commons.util.io.json.parser.ParseException: Encountered \" <IDENTIFIER> \"x \"\" at line 1, column 39.\r\nWas expecting one of:\r\n \"false\" ...\r\n \"null\" ...\r\n \"true\" ...\r\n <INTEGER_LITERAL> ...\r\n <FLOATING_POINT_LITERAL> ...\r\n <STRING_LITERAL> ...\r\n \"{\" ...\r\n \"[\" ...\r\n \r\n\tat com.ibm.commons.util.io.json.parser.Json.generateParseException(Json.java:637)\r\n\tat com.ibm.commons.util.io.json.parser.Json.jj_consume_token(Json.java:572)\r\n\tat com.ibm.commons.util.io.json.parser.Json.literal(Json.java:230)\r\n\tat com.ibm.commons.util.io.json.parser.Json.propertyNameAndValueList(Json.java:274)\r\n\tat com.ibm.commons.util.io.json.parser.Json.objectLiteral(Json.java:244)\r\n\tat com.ibm.commons.util.io.json.parser.Json.parseJson(Json.java:383)\r\n\tat com.ibm.commons.util.io.json.JsonParser.fromJson(JsonParser.java:84)\r\n\t... 30 more\r\n"
}
Is there anyway to disable this message? Or at least remove the stack trace in the data?

Related

Python 3 exception convertion and re-raise

I have the following problem:
my application is a bridge between dbus and json-rpc.
I have a dbus library that in case of Dbus exception is raising a
DBusException("my err msg") exception.
My json-rpc library is catching all the Exception and convert it to a nice generic server error message
{"jsonrpc": "2.0", "error": {"code": -32000, "message": "Server error"}, "id": 2}
The problem is that i want to handle better those exceptions and I can distinguish between them only using the error message:
for example I need to convert the
DBusException("Invalid Parameters")
to
{"jsonrpc": "2.0", "error": {"code": -32001, "message": "Server error", data="Invalid Parameters" }, "id": 2}
that can be done raising in my library an ApiError(msg, code, data) exception.
So summarizing:
- I need to catch a DBusException
- based on the err_msg I need to switch between different exception types and re-raise a modified
ApiError exception
How is the better approach to that? this needs to be done in at least 10 functions that have the same exceptions.
1) using a decorator?
def my_exception_catcher(fun, *args, **kwargv):
try:
fun(args, *argv)
except DBusException as e
err_msg = str(e)
if err_msg == "Invalid Arguments":
raise ApiError("Server Error", code=1, data=err_msg)
else if err_msg == "Connect Error":
raise ApiError("Server Error", code=2, data=err_msg)
else:
raise
#my_exception_catcher
my_fun(*args):
do_something
2) using a function to determine the exception type?
def find_my_dbus_error(err_msg):
if err_msg == "Invalid Arguments":
return ApiError("Server Error", code=1, data=err_msg)
else if err_msg == "Connect Error":
return ApiError("Server Error", code=2, data=err_msg)
else:
return Exception(err_msg)
try:
my_fun(params)
except DBusException as e
raise find_my_dbus_error(err_msg)
3) something else?
Thanks
Nick

How to escape ":" in Logic Apps Search Query?

I want to get only new emails not reply or forwarded emails.
Here is my query:
(subject:return NOT "re:" OR subject:shipment NOT "re:") AND (attachment: return NOT exception OR attachment:shipment NOT exception) AND (subject:return NOT adjustment) AND (subject:return NOT "fw:" OR subject:shipment NOT "fw:")
But I get these error instead. These query runs fine in MS Outlook application.
{
"status": 400,
"message": "Syntax error: character ':' is not valid at position 24 in '\"(subject:return NOT \"re:\" OR subject:shipment NOT \"re:\") AND (attachment: return NOT exception OR attachment:shipment NOT exception) AND (subject:return NOT adjustment) AND (subject:return NOT \"fw:\" OR subject:shipment NOT \"fw:\")\"'.\r\nclientRequestId: c6f3d1e1-b137-4c5d-acfd-1434ff85a610\r\nserviceRequestId: 2925969d-f4df-4a84-90b1-b9977f08a024",
"error": {
"message": "Syntax error: character ':' is not valid at position 24 in '\"(subject:return NOT \"re:\" OR subject:shipment NOT \"re:\") AND (attachment: return NOT exception OR attachment:shipment NOT exception) AND (subject:return NOT adjustment) AND (subject:return NOT \"fw:\" OR subject:shipment NOT \"fw:\")\"'."
},
"source": "office365-wus2.azconn-wus2.p.azurewebsites.net"
}
You need to use the "/" escape character as explained here
| Escape | Replace: ‘"’, ‘\”‘ |

Ansible: Unexpected templating type error: expected string or buffer

I have a register with the following contents:
ok: [hostname] => {
"changed": false,
"msg": {
"changed": true,
"cmd": "cd /tmp\n ./status.sh dev",
"delta": "0:00:00.023660",
"end": "2018-11-28 17:46:05.838934",
"rc": 0,
"start": "2018-11-28 17:46:05.815274",
"stderr": "",
"stderr_lines": [],
"stdout": "application is not running. no pid file found",
"stdout_lines": [
"application is not running. no pid file found"
]
}
}
When i see the substring "not" in the register's stdout, i want to trigger another task:
- name: Starting Application As Requested
shell: /tmp/start.sh
when: operation_status.stdout | search('not')
However, i see this error in my triggered task
fatal: [host]: FAILED! => {
"failed": true,
"msg": "The conditional check 'operation_status.stdout | search('not')' failed. The error was: Unexpected templating type error occurred on ({% if operation_status.stdout | search('not') %} True {% else %} False {% endif %}): expected string or buffer\n\nThe error appears to have been in '/path/to/ansible_playbook.yml': line 46, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: Starting Application As Requested\n ^ here\n"
I only see this error when adding the when condition. Without it, my playbook succeeds. What am i doing wrong here?
Version details:
ansible 2.3.0.0
python version = 2.6.6 (r266:84292, Aug 9 2016, 06:11:56) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
This error occurs when the variable (in your case operation_status.stdout) is undefined. Maybe the status.sh script doesn't write to stdout when the service is running.
Can you put a debug task and print the value of this variable before the task with "when"?
- name: Debug print value of operation_status.stdout
debug:var=operation_status.stdout
You can also try and modify the when condition to be:
- name: Starting Application As Requested
shell: /tmp/start.sh
when: "'not' in operation_status.stdout"

GROK pattern for optional field

I have a log string like :
2018-08-02 12:02:25.904 [http-nio-8080-exec-1] WARN o.s.w.s.m.s.DefaultHandlerExceptionResolver.handleTypeMismatch - Failed to bind request element
In the above string [http-nio-8080-exec-1] is a optional field, it can be there in some log statements.
i created a grok patterns like with some references on net :
%{TIMESTAMP_ISO8601:timestamp} (\[%{DATA:thread}\])? %{LOGLEVEL:level}%{SPACE}%{JAVACLASS:class}\.%{DATA:method} - %{GREEDYDATA:loggedString}
seems its not working if i remove the thread name string.
you need to make the space character following the thread name optional: (\[%{DATA:thread}\] )?
input:
2018-08-02 12:02:25.904 WARN o.s.w.s.m.s.DefaultHandlerExceptionResolver.handleTypeMismatch - Failed to bind request element
pattern:
%{TIMESTAMP_ISO8601:timestamp} (\[%{DATA:thread}\] )?%{LOGLEVEL:level}%{SPACE}%{JAVACLASS:class}\.%{DATA:method} - %{GREEDYDATA:loggedString}
output:
{
"loggedString": "Failed to bind request element",
"method": "handleTypeMismatch",
"level": "WARN",
"class": "o.s.w.s.m.s.DefaultHandlerExceptionResolver",
"timestamp": "2018-08-02 12:02:25.904"
}

Spark Jobserver - stress test - Async POST error response: akka.pattern.AskTimeoutException

Hi I am trying to do stress test on the spark job server, and I am sharing the spark context with the following properties among the submitted jobs.
spark.executor.cores='2'
spark.cores.max='1'
spark.driver.cores='1'
spark.driver.memory='1g'
spark.executor.memory='1g'
spark.executor.instances='2'
spark.scheduler.mode='FAIR'
spark.scheduler.pool='fair_pool'
spark.scheduler.allocation.file='/spark-jobserver/scheduler.xml
When I post 10 jobs in 100 ms using Jmeter, only 4 to 5 jobs gives success respons and others give the following error:
{
"status": "ERROR",
"result": {
"message": "Ask timed out on [Actor[akka://JobServer/user/context-supervisor/admin-context#-1409264293]] after [10000 ms]. Sender[null] sent message of type \"spark.jobserver.JobManagerActor$StartJob\".",
"errorClass": "akka.pattern.AskTimeoutException",
"stack": ["akka.pattern.PromiseActorRef$$anonfun$1.apply$mcV$sp(AskSupport.scala:604)", "akka.actor.Scheduler$$anon$4.run(Scheduler.scala:126)", "scala.concurrent.Future$InternalCallbackExecutor$.unbatchedExecute(Future.scala:601)", "scala.concurrent.BatchingExecutor$class.execute(BatchingExecutor.scala:109)", "scala.concurrent.Future$InternalCallbackExecutor$.execute(Future.scala:599)", "akka.actor.LightArrayRevolverScheduler$TaskHolder.executeTask(LightArrayRevolverScheduler.scala:331)", "akka.actor.LightArrayRevolverScheduler$$anon$4.executeBucket$1(LightArrayRevolverScheduler.scala:282)", "akka.actor.LightArrayRevolverScheduler$$anon$4.nextTick(LightArrayRevolverScheduler.scala:286)", "akka.actor.LightArrayRevolverScheduler$$anon$4.run(LightArrayRevolverScheduler.scala:238)", "java.lang.Thread.run(Thread.java:748)"]
}
}
Please note that I am expecting asynchronous success response for how much ever the reponse time can be.

Resources