
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
n8n-nodes-python-raw
Advanced tools
π¨ WARNING: 100% AI-GENERATED EXPERIMENTAL CODE - HIGH RISK! Use at own risk, not for production. Python execution for n8n with file processing, multiple credentials, debug tools. Personal use only - Commons Clause license.
π¨ CRITICAL DANGER: 100% AI-GENERATED EXPERIMENTAL CODE π¨: ALL modifications and features in this fork were created using AI assistance. This code may contain CRITICAL ERRORS, security vulnerabilities, or unexpected behavior. ABSOLUTELY NOT FOR PRODUCTION USE. HIGH RISK - USE AT YOUR OWN EXTREME CAUTION.
β οΈ DISCLAIMER: This is an unofficial fork of n8n-nodes-python, not affiliated with or endorsed by n8n GmbH. The name "n8n" is used solely to indicate compatibility with the n8n platform. This project is not for commercial use - see Commons Clause license restrictions.
π€ AI-Generated Code Notice: Large portions of this codebase were developed with AI assistance. Code may contain errors or unexpected behavior. Use at your own risk.
π Personal Project: This fork was created for personal, non-commercial use and educational purposes. The maintainer assumes no responsibility for any use by third parties.
π READ FULL AI DISCLAIMER: For comprehensive details about AI-generated code risks, see AI_DISCLAIMER.md
A community fork of naskio/n8n-nodes-python for executing Python scripts with raw output control, advanced file processing capabilities, and comprehensive testing infrastructure.
Original Project: https://github.com/naskio/n8n-nodes-python by naskio - Thank you for the foundation!
This fork includes significant enhancements for raw Python script execution, structured output parsing, comprehensive file processing, and robust error handling.
β οΈ Not for Commercial Use: This software is licensed under Apache 2.0 with Commons Clause - commercial use is prohibited.
In n8n, go to Settings β Community Nodes and install:
n8n-nodes-python-raw
Input data from previous node:
[{"title": "My Video", "duration": 120, "author": "John"}]
Your Python code:
# Variables automatically extracted from input:
print(f"Processing: {title}") # "My Video"
print(f"Duration: {duration} sec") # 120 sec
print(f"Author: {author}") # "John"
# Generate a report file:
import os
report_content = f"Video: {title}\nDuration: {duration}s\nAuthor: {author}"
with open(os.path.join(output_dir, expected_filename), 'w') as f:
f.write(report_content)
print("Report generated successfully!")
Result: Direct access to your data AND automatic file processing!
The node has two outputs for better workflow control:
exitCode = 0 (successful execution)exitCode β 0 (errors or failures)Benefits: No need for conditional logic based on exitCode in your workflow!
Python Function β Output 1 (Success) β Continue Processing
β Output 2 (Error) β Error Handling/Notification
This eliminates the need to check exitCode in subsequent nodes - the routing is automatic!
Generate files in your Python scripts and automatically include them in n8n workflow output. Perfect for reports, images, data exports, and more.
output_file_path variable with complete file path (recommended)import os
import json
# Method 1: Use the ready-made path (recommended)
with open(output_file_path, 'w') as f:
json.dump({"results": "processed_data"}, f)
# Method 2: Build path manually using provided variables
file_path = os.path.join(output_dir, expected_filename)
with open(file_path, 'w') as f:
f.write("Report content")
# Create file with the exact filename specified
# n8n will automatically find it after script execution
with open(expected_filename, 'w') as f:
f.write("Generated content")
# Or in a subdirectory - n8n will find it recursively
os.makedirs("reports", exist_ok=True)
with open(os.path.join("reports", expected_filename), 'w') as f:
f.write("Report in subfolder")
import os
from reportlab.pdfgen import canvas
# Create PDF report
pdf_path = output_file_path # or os.path.join(output_dir, expected_filename)
c = canvas.Canvas(pdf_path)
c.drawString(100, 750, f"Report for {title}")
c.drawString(100, 730, f"Duration: {duration} seconds")
c.save()
print("PDF report generated!")
import csv
import os
# Process data and export to CSV
csv_path = output_file_path
with open(csv_path, 'w', newline='') as csvfile:
writer = csv.writer(csvfile)
writer.writerow(['Title', 'Duration', 'Author'])
for item in input_items:
writer.writerow([item.get('title'), item.get('duration'), item.get('author')])
print(f"Exported {len(input_items)} items to CSV")
import subprocess
import os
from shutil import which
# Ensure ffmpeg is available
if which("ffmpeg") is None:
print("Error: ffmpeg not found")
exit(1)
# Generate test video
cmd = [
"ffmpeg", "-y",
"-f", "lavfi", "-i", "testsrc=size=1280x720:rate=30:duration=5",
"-f", "lavfi", "-i", "sine=frequency=1000:sample_rate=44100:duration=5",
"-c:v", "libx264", "-pix_fmt", "yuv420p",
"-c:a", "aac", "-b:a", "128k",
output_file_path
]
subprocess.run(cmd, check=True)
print("Test video generated successfully!")
Comprehensive debugging system for troubleshooting file processing issues with detailed diagnostics.
{
"fileDebugInfo": {
"input_files": {
"count": 2,
"total_size_mb": 5.47,
"files_by_type": {"image/jpeg": 1, "application/pdf": 1},
"files_details": [...],
"processing_errors": []
},
"output_files": {
"processing_enabled": true,
"output_directory": "/tmp/n8n_output_xyz",
"directory_exists": true,
"directory_writable": true,
"found_files": [...],
"scan_errors": []
},
"system_info": {
"python_executable": "/usr/bin/python3",
"working_directory": "/app",
"user_permissions": {"can_write_temp": true},
"environment_variables": {"output_dir_available": true}
},
"directory_listings": {
"working_directory": [...],
"output_directory": [...]
}
}
}
output_dir variable not available β Solution: Check system_info.environment_variablesChoose export format for generated scripts in "Export Script" debug mode to comply with security policies.
output_file_path variable (recommended)When Debug Mode is set to "Export Script", the node generates two downloadable files:
.py or .txt (configurable via Script Export Format)python_script_TIMESTAMP.py (or python_script_error_TIMESTAMP.py for errors)output_TIMESTAMP.json{
"timestamp": "2025-06-05T12:00:00.000Z",
"execution_results": {
"exitCode": 0,
"success": true,
"stdout": "script output",
"stderr": "",
"parsed_stdout": {...},
"parsing_success": true,
"executedAt": "2025-06-05T12:00:00.000Z",
"inputItemsCount": 1,
"executionMode": "once"
},
"export_info": {
"description": "Π Π΅Π·ΡΠ»ΡΡΠ°ΡΡ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ Python ΡΠΊΡΠΈΠΏΡΠ° ΠΈΠ· n8n",
"format_version": "1.0",
"exported_at": "2025-06-05T12:00:00.000Z",
"node_type": "n8n-nodes-python.pythonFunction"
}
}
The node returns a comprehensive result object:
{
"exitCode": 0, // 0 = success (routes to Output 1), non-zero = error (routes to Output 2), -2 = timeout
"stdout": "raw output string",
"stderr": "error messages",
"success": true,
"error": null,
"inputItemsCount": 1,
"executedAt": "2025-06-02T12:00:00.000Z",
"injectVariables": true,
"parseOutput": "none",
"executionMode": "once",
// Output File Processing results (when enabled)
"outputFiles": [
{
"filename": "report.pdf",
"size": 1024000,
"mimetype": "application/pdf",
"extension": "pdf",
"binaryKey": "report.pdf",
"createdAt": "2025-06-02T12:00:00.000Z"
}
],
"outputFilesCount": 1,
// Parsing results (when enabled)
"parsed_stdout": {"key": "value"},
"parsing_success": true,
"parsing_error": null,
"output_format": "json",
"parsing_method": "json",
// File Debug Information (when enabled)
"fileDebugInfo": {
"input_files": {...},
"output_files": {...},
"system_info": {...},
"directory_listings": {...}
},
// Error details (on failure)
"pythonError": {
"errorType": "ImportError",
"errorMessage": "No module named 'requests'",
"missingModules": ["requests"],
"traceback": "full traceback",
"lineNumber": 5
},
"detailedError": "comprehensive error description"
}
import os
import json
# Create a data analysis report
report_data = {
"total_items": len(input_items),
"analysis": "completed",
"timestamp": "2025-06-02T12:00:00Z"
}
# Save as JSON file using the ready-made path
with open(output_file_path, 'w') as f:
json.dump(report_data, f, indent=2)
print(f"Report saved to {expected_filename}")
Configuration:
Result: JSON file automatically included as binary data in n8n output
import os
import json
import csv
# Create multiple output files
os.makedirs(output_dir, exist_ok=True)
# 1. Generate summary JSON
summary = {"processed": len(input_items), "status": "complete"}
with open(os.path.join(output_dir, "summary.json"), 'w') as f:
json.dump(summary, f)
# 2. Generate detailed CSV
with open(os.path.join(output_dir, expected_filename), 'w', newline='') as f:
writer = csv.writer(f)
writer.writerow(['Title', 'Duration'])
for item in input_items:
writer.writerow([item.get('title'), item.get('duration')])
print("Multiple files generated")
Configuration:
Result: Both summary.json and details.csv files are automatically detected and included
import os
from PIL import Image, ImageDraw
# Create a simple chart image
img = Image.new('RGB', (800, 600), color='white')
draw = ImageDraw.Draw(img)
# Draw title
draw.text((50, 50), f"Analysis Results", fill='black')
draw.text((50, 100), f"Total Items: {len(input_items)}", fill='blue')
# Save image
img.save(output_file_path)
print(f"Chart saved as {expected_filename}")
Configuration:
Result: PNG image automatically included as binary data
# Using multiple API credentials to fetch data and generate report
import requests
import json
import os
# Access different service credentials
api1_data = requests.get(f"https://api1.com/data",
headers={"Authorization": f"Bearer {API1_TOKEN}"}).json()
api2_data = requests.get(f"https://api2.com/stats",
headers={"X-API-Key": API2_KEY}).json()
# Combine data and generate report
combined_report = {
"api1_results": api1_data,
"api2_results": api2_data,
"generated_at": "2025-06-02T12:00:00Z",
"total_items": len(input_items)
}
# Save comprehensive report
with open(output_file_path, 'w') as f:
json.dump(combined_report, f, indent=2)
print("Multi-API report generated")
Configuration:
Result: Report with data from multiple APIs saved as downloadable file
When "Inject Variables" is enabled (default), the node automatically injects powerful variables into your Python script:
title, duration, author)output_dir: Unique temporary directory for file generation (when Output File Processing enabled)expected_filename: Filename specified in configuration (when Output File Processing enabled)output_file_path: Complete file path for output file (when using Ready Variable Path mode)env_vars: Dictionary of environment variables (from credentials or system, optional)# Input from previous n8n node:
[
{"title": "Video 1", "duration": 120, "author": "John"},
{"title": "Video 2", "duration": 90, "author": "Jane"}
]
# Automatically available variables (from first item):
title = "Video 1" # Direct access
duration = 120 # No indexing needed
author = "John" # Clean variable names
# File processing variables (when enabled):
output_dir = "/tmp/n8n_python_output_12345"
expected_filename = "report.pdf"
output_file_path = "/tmp/n8n_python_output_12345/report.pdf"
# Legacy compatibility (optional):
env_vars = {...} # Environment variables dictionary
Benefits:
title instead of input_items[0]['title']video-name β video_name)import json
import os
print(f"Processing {len(input_items)} items total")
print(f"First item: {title}") # From first item
# Generate summary report
summary = {
"total_items": len(input_items),
"first_title": title,
"all_titles": [item.get('title') for item in input_items]
}
# Save to file
with open(output_file_path, 'w') as f:
json.dump(summary, f, indent=2)
import json
import os
# Variables extracted from current item
print(f"Processing: {title}") # Current item's title
print(f"Duration: {duration}") # Current item's duration
# Generate individual report file
report = {
"item_title": title,
"item_duration": duration,
"processed_at": "2025-06-02T12:00:00Z"
}
# Each item gets its own output file
with open(output_file_path, 'w') as f:
json.dump(report, f, indent=2)
output_dir variable not availableSolution:
Solution:
Solution:
Solution:
Problem: NameError: name 'os' is not defined
Solution: Add required imports to your script:
import os
import subprocess
import json
from shutil import which
# ... your code
expected_filename variable and enhanced output file processing instructionsComprehensive documentation is available in the docs/ directory:
Apache License 2.0 with Commons Clause - see LICENSE.md
β οΈ IMPORTANT DISCLAIMERS:
THE MAINTAINER ACCEPTS NO RESPONSIBILITY WHATSOEVER FOR:
Large portions of this codebase were developed with AI assistance. CRITICAL RISKS:
MANDATORY REQUIREMENTS BEFORE USE:
This software is licensed under Apache License 2.0 with Commons Clause, which prohibits commercial use. You may not sell, distribute for a fee, or use this software in any commercial product or service.
This software is provided "AS IS" without warranty of any kind. The maintainer assumes NO RESPONSIBILITY for:
Use at your own risk and thoroughly test before any production use.
This fork was created for personal, non-commercial use and educational purposes only. It is not intended for:
This is a community-maintained fork. Contributions welcome!
FAQs
π¨ WARNING: 100% AI-GENERATED EXPERIMENTAL CODE - HIGH RISK! Use at own risk, not for production. Python execution for n8n with file processing, multiple credentials, debug tools. Personal use only - Commons Clause license.
The npm package n8n-nodes-python-raw receives a total of 45 weekly downloads. As such, n8n-nodes-python-raw popularity was classified as not popular.
We found that n8n-nodes-python-raw demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.