Fix: Resolved E2BIG error by switching to file-based payload passing for large requests (images)
This commit is contained in:
@@ -379,17 +379,28 @@ def main():
|
||||
"""
|
||||
parser = argparse.ArgumentParser(description="GTM Architect Orchestrator")
|
||||
parser.add_argument("--mode", required=True, help="The execution mode (e.g., phase1, phase2).")
|
||||
parser.add_argument("--payload_base64", required=True, help="The Base64 encoded JSON payload.")
|
||||
parser.add_argument("--payload_base64", help="The Base64 encoded JSON payload (deprecated, use payload_file).")
|
||||
parser.add_argument("--payload_file", help="Path to a JSON file containing the payload (preferred).")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
payload = {}
|
||||
try:
|
||||
payload_str = base64.b64decode(args.payload_base64).decode('utf-8')
|
||||
payload = json.loads(payload_str)
|
||||
except (json.JSONDecodeError, base64.binascii.Error) as e:
|
||||
logging.error(f"Failed to decode payload: {e}")
|
||||
if args.payload_file:
|
||||
if not os.path.exists(args.payload_file):
|
||||
raise FileNotFoundError(f"Payload file not found: {args.payload_file}")
|
||||
with open(args.payload_file, 'r', encoding='utf-8') as f:
|
||||
payload = json.load(f)
|
||||
elif args.payload_base64:
|
||||
payload_str = base64.b64decode(args.payload_base64).decode('utf-8')
|
||||
payload = json.loads(payload_str)
|
||||
else:
|
||||
raise ValueError("No payload provided (neither --payload_file nor --payload_base64).")
|
||||
|
||||
except (json.JSONDecodeError, base64.binascii.Error, ValueError, FileNotFoundError) as e:
|
||||
logging.error(f"Failed to load payload: {e}")
|
||||
# Print error as JSON to stdout for the server to catch
|
||||
print(json.dumps({"error": "Invalid payload format.", "details": str(e)}))
|
||||
print(json.dumps({"error": "Invalid payload.", "details": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
# Function mapping to dynamically call the correct phase
|
||||
|
||||
Reference in New Issue
Block a user