Category: Integration
Node id: function
Maturity: production
Risk tier: none
Executes custom code in JavaScript, Python, or Bash. NOTE: sandbox isolation is not yet enabled — code runs with service privileges, so only trusted, reviewed code belongs in this node.
What it does
- Four runtime environments: JavaScript, Python, Bash, Go
- Configurable execution timeout
- JSON input/output serialization for data exchange
- Stdout/stderr capture for debugging
- Execution duration tracking in milliseconds
Use cases
- Run custom data transformation logic not covered by built-in nodes
- Execute Python scripts for clinical data normalization
- Run shell commands for system integration tasks
Runtime
- Performance tier:
variable
Output ports
Settings
Basic
Advanced
Errors
Runtime notes
- output is the code's return value (JavaScript/Python:
return a JSON-serialisable value; the runtime writes it as the last __OUTPUT__:JSON line, so never print __OUTPUT__ yourself). bash prints __OUTPUT__:<json> as its last line; without a marker output is the raw stdout string
- Python: code is the body of a function (user_function) and the runtime indents it, so it runs whether its lines start at column 0 or are all indented by the same amount; json, sys, inputs and context are predefined; use
return, not print, for the result. An IndentationError means inconsistent indentation inside the code, not a missing indent
- print/console.log output is kept in result.stdout for debugging; it becomes output only when the code returns nothing (null/None/undefined)
- Go runtime is declared but not yet implemented — use javascript, python, or bash
- Function code receives inputs as a pre-parsed variable (JS: inputs; Python: inputs dict); bash reads them as JSON on standard input
- Function code receives the run context as a separate variable
context = {run_id, pipeline_id, pipeline_version, node_id, started_at} (bash: HYDRA_RUN_ID, HYDRA_PIPELINE_ID, HYDRA_PIPELINE_VERSION, HYDRA_NODE_ID, HYDRA_RUN_STARTED_AT, HYDRA_RUN_CONTEXT); it never carries the caller identity, org id or secrets
- Code and inputs reach the interpreter on standard input (bash: a 0600 script file removed after the run), never on the command line; max_input_bytes bounds the serialized inputs
- An exception (JavaScript/Python), a non-zero exit (bash) or a timeout fails the node; the error carries the message and the top of the stack (truncated). Use node-level error_handling (continue/fallback) to proceed past a failure
- No sandbox: code executes with the service's OS privileges — treat configs as trusted code (BR-2)
See Build any workflow for how to put nodes together and Ports, types and data flow for how port types connect.