Comment on page

Testing Transforms

Transforms can be tested as you develop them by using the runreveal transform test command.
This command requires the argument --file or -f which will specify the code that you want to test. Along with the source code is the data you'd like transform.
$ runreveal
When running the transform command, the entire Event that we store gets printed, along with any errors that were encountered when executing your transform. Here's an example invocation of our tailscale transform.
$ transform test --file --data data.json
"Event": {
"id": "2QWXKsRgsoVos0W8RGpZySpGUW0",
"workspace_id": "2KUOdhvRReF5RZfQX8ILneT4fSd",
"source_type": "webhook",
"source_id": "1",
"log": {
"data": {
"actor": "[email protected]",
"deviceName": "",
"managedBy": "tag:production",
"nodeID": "n79eR77CNTRL",
"url": ""
"message": "Node created",
"tailnet": "",
"timestamp": "2023-05-23T15:54:23.498133536Z",
"type": "nodeCreated",
"version": 1
"raw_log": "eyJ0aW1lc3RhbXAiOiIyMDIzLTA1LTIzVDE1OjU0OjIzLjQ5ODEzMzUzNloiLCJ2ZXJzaW9uIjoxLCJ0eXBlIjoibm9kZUNyZWF0ZWQiLCJ0YWlsbmV0IjoicnVucmV2ZWFsLmNvbSIsIm1lc3NhZ2UiOiJOb2RlIGlwLTE3Mi0zMC0xLTEwMi50YWlsOTI4N2IudHMubmV0IGNyZWF0ZWQiLCJkYXRhIjp7Im5vZGVJRCI6Im43OWVSNzdDTlRSTCIsInVybCI6Imh0dHBzOi8vbG9naW4udGFpbHNjYWxlLmNvbS9hZG1pbi9tYWNoaW5lcy8xMDAuMTE1LjczLjczIiwiZGV2aWNlTmFtZSI6ImlwLTE3Mi0zMC0xLTEwMi50YWlsOTI4N2IudHMubmV0IiwibWFuYWdlZEJ5IjoidGFnOnByb2R1Y3Rpb24iLCJhY3RvciI6ImV2YW5AcnVucmV2ZWFsLmNvbSJ9fQo=",
"normalized": {
"id": "",
"event_time": "2023-05-23T15:54:23Z",
"event_name": "nodeCreated",
"read_only": false,
"actor": {},
"src": {},
"dst": {},
"tags": {
"device_name": "n79eR77CNTRL",
"node_id": "n79eR77CNTRL",
"tailnet": "",
"Error": ""

Printing Errors

If a python error exists while running your transform, the results of that error can be pretty printed using the jq command. Piping the output of the command to jq -r .Error will pretty print the results of Error including all python formatting.
$ ./dist/runreveal/runreveal transform test --file --data data.json | jq -r .Error
Traceback (most recent call last):
File "/", line 75, in main
resp = v.transform(evt)
File "/", line 2, in transform
return false
NameError: name 'false' is not defined
:) cat
def transform(event):
return false