From cfc3064f39ddb80f8636aa7b4c3a734ef83abae5 Mon Sep 17 00:00:00 2001 From: Nubenetes Bot Date: Sun, 10 May 2026 21:57:47 +0200 Subject: [PATCH] fix: handle 404 for new files in GitOps and suppress BS4 XML warnings --- src/agentic_curator.py | 3 +++ src/gitops_manager.py | 32 ++++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/agentic_curator.py b/src/agentic_curator.py index 7d4077e0..59adfdaa 100644 --- a/src/agentic_curator.py +++ b/src/agentic_curator.py @@ -15,6 +15,9 @@ async def _deep_fetch_content(url: str) -> str: resp = await client.get(url, timeout=10, headers=headers) if resp.status_code == 200: html = resp.text + from bs4 import BeautifulSoup, XMLParsedAsHTMLWarning + import warnings + warnings.filterwarnings("ignore", category=XMLParsedAsHTMLWarning) soup = BeautifulSoup(html, 'html.parser') for s in soup(['script', 'style', 'nav', 'footer']): s.decompose() diff --git a/src/gitops_manager.py b/src/gitops_manager.py index fe27b7eb..32ba0dd6 100644 --- a/src/gitops_manager.py +++ b/src/gitops_manager.py @@ -21,17 +21,29 @@ class RepositoryController: for file_path, content in updates.items(): try: - file_meta = self.repository.get_contents(file_path, ref=self.default_branch_name) - commit_signature = f"chore(docs): optimizar y curar {file_path} [{timestamp_slug}]" - self.repository.update_file( - path=file_path, - message=commit_signature, - content=content, - sha=file_meta.sha, - branch=branch_name - ) + commit_signature = f"chore: update {file_path} [{timestamp_slug}]" + try: + file_meta = self.repository.get_contents(file_path, ref=self.default_branch_name) + self.repository.update_file( + path=file_path, + message=commit_signature, + content=content, + sha=file_meta.sha, + branch=branch_name + ) + except Exception as e: + # Si no existe (404), lo creamos + if "404" in str(e): + self.repository.create_file( + path=file_path, + message=f"chore: create {file_path} [{timestamp_slug}]", + content=content, + branch=branch_name + ) + else: + raise e except Exception as e: - print(f"Error actualizando {file_path}: {e}") + print(f"Error procesando {file_path}: {e}") # Informe Visual en el PR categories_str = ", ".join([f"`{c}`" for c in metrics.get('categories', [])])