Fix script execution logs being lost
- Add ScriptExecutionError class that preserves captured logs/queries - IsolatedScriptExecutor: throw ScriptExecutionError with accumulated logs instead of plain Error on script failure - ScriptExecutor (Python): same fix for Python execution errors - testEndpoint: return captured logs/queries on script errors - dynamicApiController: correctly extract scriptResult.result instead of stuffing entire IsolatedExecutionResult into rows; include logs in detailed_response output Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@ import { Response } from 'express';
|
||||
import { AuthRequest } from '../middleware/auth';
|
||||
import { mainPool } from '../config/database';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { ExportedEndpoint, ExportedScriptQuery } from '../types';
|
||||
import { ExportedEndpoint, ExportedScriptQuery, ScriptExecutionError } from '../types';
|
||||
import { encryptEndpointData, decryptEndpointData } from '../services/endpointCrypto';
|
||||
|
||||
export const getEndpoints = async (req: AuthRequest, res: Response) => {
|
||||
@@ -388,13 +388,14 @@ export const testEndpoint = async (req: AuthRequest, res: Response) => {
|
||||
return res.status(400).json({ error: 'Invalid execution_type' });
|
||||
}
|
||||
} catch (error: any) {
|
||||
const isScriptError = error instanceof ScriptExecutionError;
|
||||
res.status(400).json({
|
||||
success: false,
|
||||
error: error.message,
|
||||
detail: error.detail || undefined,
|
||||
hint: error.hint || undefined,
|
||||
logs: [],
|
||||
queries: [],
|
||||
logs: isScriptError ? error.logs : [],
|
||||
queries: isScriptError ? error.queries : [],
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user