NappaiSandbox
The Nappai Sandbox provides a safe, isolated space where you can run code scripts and agent actions without affecting the rest of your system. It acts as a secure container that evaluates your code, processes tasks, and returns results along with detailed logs and error information. This component is ideal for executing data processing tasks, transforming information, or automating processes in a controlled environment.
How it Works
When you provide code to the Nappai Sandbox, it runs that code inside a protected box. This means your code executes safely and cannot accidentally damage your data or system. The sandbox handles the heavy lifting of executing the code, managing resources, and ensuring security limits are respected. Once the code finishes running, the sandbox collects the output, captures any messages generated during the process, and reports the final result or any errors that occurred.
Inputs
Input Fields
- Code to Run: The script or code snippet that needs to be executed inside the isolated environment. This field is required and expects a string containing your code.
- Visible in: All operations
- Execution Context: Variables, state information, or metadata that can be shared with the code being executed. Use this to pass data into your script from the workflow. Default is an empty container.
- Visible in: All operations
- Environment Configuration: Settings that control how the sandbox operates, such as security rules, time limits for execution, or specific permissions. This allows you to customize the safety and behavior of the execution. Uses system defaults if not specified.
- Visible in: All operations
Outputs
The Nappai Sandbox produces the following outputs after execution:
- Execution Result: The final value returned by your code. This could be a processed dataset, a transformed string, or a confirmation status. You can connect this to other components to use the processed data in your workflow.
- Output Log: A record of messages generated during the execution, such as standard output or error messages. This is useful for debugging and understanding what happened during the process.
- Error Information: If the code fails to run correctly, this output contains details about the error, helping you diagnose and fix issues in your code or configuration.
Output Data Example (JSON)
json { “result”: { “status”: “success”, “processed_data”: “Formatted text output” }, “output_logs”: “Executing code…\nProcess completed successfully.”, “error_info”: null }
Connectivity
The Nappai Sandbox is a versatile component used in automation workflows to execute code safely. Here are typical connections:
- Input Connections: Connect the output of a Code Generator, Text Editor, or Data Transformer to the Code to Run input. Connect Data Source components to the Execution Context input to provide variables for your script.
- Output Connections: Route the Execution Result to downstream components like Data Storage, Notification triggers, or further Processors to use the outcome of the code execution. Use the Output Log for monitoring and debugging purposes. If Error Information contains a failure, you can branch your workflow to handle errors or retry logic.
Usage Example
Scenario: Formatting a Date in an Automation Workflow
- Setup: Add the Nappai Sandbox component to your workflow.
- Input: In the Code to Run field, write a simple script to format a date:
return date_obj.strftime("%Y-%m-%d"). - Context: Map a date string from a previous component (e.g., “2023/10/05”) to the Execution Context input as a variable.
- Execution: The Sandbox executes the code safely.
- Result: The Execution Result output provides the formatted date:
2023-10-05. - Next Step: Connect the result to a Send Email component to include the formatted date in the message.
Tips and Best Practices
- Keep your code snippets concise to ensure fast execution and easier debugging.
- Use the Output Log to check for warnings or unexpected behavior during execution.
- Ensure your code handles potential errors gracefully, as the Sandbox will capture and report them via the Error Information output.
- Remember that the sandbox runs in an isolated environment; your code cannot access external resources unless explicitly allowed by the configuration.
Security Considerations
The Nappai Sandbox is designed with security in mind. It runs code in an isolated environment to prevent unauthorized access to your system or data. All executions are subject to security rules and time limits to protect your workflow. Always review the code inputs and rely on the built-in safety mechanisms to ensure safe automation.