From 209b36357765e9e6e0146041c0008d6ae9375224 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 17 Sep 2026 06:22:30 +0000 Subject: [PATCH 1/3] fix(deploy): robustly handle markdown formatting in LLM generated json Extract json block from markdown wrapper using regex in the unattended deployment script (`scripts/automatizacion_despliegue.py`) to prevent failure when LLM-generated promotional content is wrapped with backticks. Co-authored-by: LVT-ENG <214667862+LVT-ENG@users.noreply.github.com> --- scripts/automatizacion_despliegue.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/automatizacion_despliegue.py b/scripts/automatizacion_despliegue.py index bcbe56aab8..96656173df 100644 --- a/scripts/automatizacion_despliegue.py +++ b/scripts/automatizacion_despliegue.py @@ -13,6 +13,7 @@ import shutil import argparse import subprocess +import re from typing import Any, Dict, cast SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) @@ -40,13 +41,19 @@ def process_file(filepath: str, dry_run: bool) -> bool: with open(filepath, "r", encoding="utf-8") as f: contenido_archivo = f.read() + match = re.search(r"```(?:json)?\s*(\{.*?\})\s*```", contenido_archivo, re.DOTALL) + if match: + contenido_limpio = match.group(1).strip() + else: + contenido_limpio = contenido_archivo.strip() + try: - datos_cargados = json.loads(contenido_archivo) + datos_cargados = json.loads(contenido_limpio) except json.JSONDecodeError as e: # Fallback en caso de que el LLM incluya texto extra if e.pos > 0: try: - datos_cargados = json.loads(contenido_archivo[:e.pos]) + datos_cargados = json.loads(contenido_limpio[:e.pos]) except json.JSONDecodeError: raise ValueError(f"Error parseando JSON incluso con el texto extra cortado.") else: From c47db0ae5b79da3251bef013d071cacfa58f0506 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 17 Sep 2026 06:26:32 +0000 Subject: [PATCH 2/3] fix(deploy): robustly handle markdown formatting in LLM generated json and fix lints Extract json block from markdown wrapper using regex in the unattended deployment script (`scripts/automatizacion_despliegue.py`) to prevent failure when LLM-generated promotional content is wrapped with backticks. Fixed linter issues (import sorting and raising exception from err). Co-authored-by: LVT-ENG <214667862+LVT-ENG@users.noreply.github.com> --- scripts/automatizacion_despliegue.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/automatizacion_despliegue.py b/scripts/automatizacion_despliegue.py index 96656173df..a4f140e132 100644 --- a/scripts/automatizacion_despliegue.py +++ b/scripts/automatizacion_despliegue.py @@ -7,13 +7,13 @@ """ import os +import re import sys import json import time import shutil import argparse import subprocess -import re from typing import Any, Dict, cast SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) @@ -54,8 +54,8 @@ def process_file(filepath: str, dry_run: bool) -> bool: if e.pos > 0: try: datos_cargados = json.loads(contenido_limpio[:e.pos]) - except json.JSONDecodeError: - raise ValueError(f"Error parseando JSON incluso con el texto extra cortado.") + except json.JSONDecodeError as err: + raise ValueError(f"Error parseando JSON incluso con el texto extra cortado.") from err else: raise From 21101c139d656aa6e54bfeda9fd9644206c2ec21 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 17 Sep 2026 06:32:57 +0000 Subject: [PATCH 3/3] fix(deploy): robustly handle markdown formatting in LLM generated json and fix lints Extract json block from markdown wrapper using regex in the unattended deployment script (`scripts/automatizacion_despliegue.py`) to prevent failure when LLM-generated promotional content is wrapped with backticks. Fixed linter issues (`I001` and `B904` from Ruff in `automatizacion_despliegue.py`, and missing return type for `main()` from pyright in `auto_deploy_v2.py`). Co-authored-by: LVT-ENG <214667862+LVT-ENG@users.noreply.github.com> --- scripts/auto_deploy_v2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_deploy_v2.py b/scripts/auto_deploy_v2.py index d0638d84a3..85c06ff470 100755 --- a/scripts/auto_deploy_v2.py +++ b/scripts/auto_deploy_v2.py @@ -14,7 +14,7 @@ def validar_promocion(data: Dict[str, Any]) -> None: if campo not in data: raise ValueError(f"Falta el campo requerido: {campo}") -def main(): +def main() -> None: if len(sys.argv) < 2: print("Uso: python3 auto_deploy_v2.py ") sys.exit(1)