-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Format option should affect the output formatting of exceptions on STDERR for the CLI #323
Comments
@emmacasolin when you come up with the format here, can you also update the issue description here later. Some of the notes above will be out of date. |
For the human readable errors I have a method that produces the following output: Standard error
PK error (not ErrorPolykeyRemote)
ErrorPolykeyRemote wrapping a PK error
Two ErrorPolykeyRemotes wrapping a PK error with a cause
I don't like that a PK error with an empty |
In |
Yea, that is correct. You will have to dynamic formatting change. The exit handlers are setup before the root command They are used in both So you'll need to make the Then inside the In the case of |
Specifying `--format=json` will cause errors to be logged in json format. ErrorPolykeyRemote errors also now contain additional metadata about the origin node of the error. #323
Examples of the new error logging style: # Single error (no cause)
# --format=human (default)
ErrorStatusLocked: Status is locked by another process
exitCode 75
timestamp Mon May 23 2022 15:25:08 GMT+1000 (Australian Eastern Standard Time)
# --format=json
{"type":"ErrorStatusLocked","data":{"message":"","timestamp":"2022-05-23T05:00:32.049Z","data":{},"stack":"ErrorStatusLocked\n at constructor_.start (/home/emma/Projects/js-polykey/src/status/Status.ts:53:13)\n at async /home/emma/Projects/js-polykey/node_modules/@matrixai/async-init/src/StartStop.ts:56:24\n at async withF (/home/emma/Projects/js-polykey/node_modules/@matrixai/resources/src/utils.ts:24:12)\n at async Object.bootstrapState (/home/emma/Projects/js-polykey/src/bootstrap/utils.ts:73:5)\n at async /home/emma/Projects/js-polykey/src/bin/bootstrap/CommandBootstrap.ts:24:31\n at async CommandBootstrap.<anonymous> (/home/emma/Projects/js-polykey/src/bin/CommandPolykey.ts:75:7)\n at async CommandPolykey.parseAsync (/home/emma/Projects/js-polykey/node_modules/commander/lib/command.js:923:5)\n at async main (/home/emma/Projects/js-polykey/src/bin/polykey.ts:54:5)\n at async /home/emma/Projects/js-polykey/src/bin/polykey.ts:103:5","exitCode":75}}
# Remote error with cause
# --format=human (default)
ErrorPolykeyRemote: Remote error from RPC call
command nodesPing
nodeId vasrqbpb1u51khi7ibg5j63ai3odomhj6js348k1ra5jffjuvrhsg
host 127.0.0.1
port 37595
timestamp Mon May 23 2022 15:25:21 GMT+1000 (Australian Eastern Standard Time)
remote error: ErrorNodeGraphEmptyDatabase: NodeGraph database was empty
exitCode 64
timestamp Mon May 23 2022 15:25:21 GMT+1000 (Australian Eastern Standard Time)
# --format=json
{"type":"ErrorPolykeyRemote","data":{"message":"","timestamp":"2022-05-23T04:56:47.661Z","data":{},"cause":{"type":"ErrorNodeGraphEmptyDatabase","data":{"message":"","timestamp":"2022-05-23T04:56:47.648Z","data":{},"stack":"ErrorNodeGraphEmptyDatabase\n at constructor_.getClosestGlobalNodes (/home/emma/Projects/js-polykey/src/nodes/NodeConnectionManager.ts:456:13)\n at async constructor_.findNode (/home/emma/Projects/js-polykey/src/nodes/NodeConnectionManager.ts:373:17)\n at async NodeManager.pingNode (/home/emma/Projects/js-polykey/src/nodes/NodeManager.ts:58:7)\n at async Object.nodesPing (/home/emma/Projects/js-polykey/src/client/service/nodesPing.ts:48:22)","exitCode":64}},"stack":"ErrorPolykeyRemote\n at toError (/home/emma/Projects/js-polykey/src/grpc/utils/utils.ts:202:29)\n at Object.callback (/home/emma/Projects/js-polykey/src/grpc/utils/utils.ts:380:17)\n at Object.onReceiveStatus (/home/emma/Projects/js-polykey/node_modules/@grpc/grpc-js/src/client.ts:351:26)\n at /home/emma/Projects/js-polykey/node_modules/@grpc/grpc-js/src/call-stream.ts:206:27\n at Object.onReceiveStatus (/home/emma/Projects/js-polykey/src/grpc/utils/FlowCountInterceptor.ts:57:13)\n at InterceptingListenerImpl.onReceiveStatus (/home/emma/Projects/js-polykey/node_modules/@grpc/grpc-js/src/call-stream.ts:202:19)\n at /home/emma/Projects/js-polykey/node_modules/@grpc/grpc-js/src/call-stream.ts:206:27\n at Object.onReceiveStatus (/home/emma/Projects/js-polykey/node_modules/@grpc/grpc-js/src/client-interceptors.ts:163:5)\n at InterceptingListenerImpl.onReceiveStatus (/home/emma/Projects/js-polykey/node_modules/@grpc/grpc-js/src/call-stream.ts:202:19)\n at Object.onReceiveStatus (/home/emma/Projects/js-polykey/node_modules/@grpc/grpc-js/src/client-interceptors.ts:462:34)","exitCode":64,"metadata":{"nodeId":{"type":"IdInternal","data":[87,55,165,229,97,241,67,72,200,242,92,11,51,13,82,30,27,139,70,102,159,6,68,80,59,81,102,247,207,223,220,121]},"host":"127.0.0.1","port":37595,"command":"nodesPing"}}} Normal logger messages remain the same (i.e. are not affected by the format option). This can be addressed later in MatrixAI/js-logger#3. |
We'll have another issue addressing the usability experience of the CLI errors. I imagine we would combine So for now, the Not showing the stack is fine for now. We can figure that out in the usability part. As for |
Specifying `--format=json` will cause errors to be logged in json format. ErrorPolykeyRemote errors also now contain additional metadata about the origin node of the error. #323
The error reporting verbosity control is here MatrixAI/Polykey-CLI#17. That can be addressed in the future. |
Specifying `--format=json` will cause errors to be logged in json format. ErrorPolykeyRemote errors also now contain additional metadata about the origin node of the error. #323
Specifying `--format=json` will cause errors to be logged in json format. ErrorPolykeyRemote errors also now contain additional metadata about the origin node of the error. #323
Specifying `--format=json` will cause errors to be logged in json format. ErrorPolykeyRemote errors also now contain additional metadata about the origin node of the error. #323
According to @emmacasolin I believe this is done. However right now structured logging (MatrixAI/js-logger#3) is not available yet, so the |
Specification
Now that we centralised all of our error functionality into https://github.com/MatrixAI/js-errors, we have a more structured way of creating and propagating way. Due to this, we need our output for these errors to become more formalised as well in order to display this information. We need to be able to communicate the information from our errors to both humans and machines, so we need to modify the
--format
option to apply to the STDERR as well as the STDOUT.Readable details included in both styles of output would need to include:
data
propertyThe json output is the most simple to achieve, since we now have
toJSON
andfromJSON
methods for our errors that allow them to be serialised and deserialised easily.toJSON
is called automatically wheneverJSON.stringify()
is called, so nothing needs to change about how we already handle the output of json data (except for handling non-polykey errors, which have notoJSON
method).A bit more thought needs to go into the human-readable output style, for example:
There is one point of ambiguity, which is that of logging for the PK agent. When starting the PK agent, we can use the
--format
option, but this would affect the output of the starting command and the output of logs going to STDERR for the agent process. Should this be 2 separate options? I believe this has been discussed here MatrixAI/js-logger#3 (comment) and the conclusion was that no, it should be 1 option, and it affects STDOUT, STDERR of the CLI command as well as the STDERR logging of the agent process if any.This means that the format option needs to be propagated to the exit handlers, as well as the error loggers in
polykey-agent.ts
. This requires dynamic setting of the format property after it has been passed in as an option.Additional context
Tasks
--format
option toCommandPolykey
(and all subcommands), the exit handlers, andpolykey-agent
The text was updated successfully, but these errors were encountered: