bug(pipelines): shortcode stripping deletes text between a {{< >}} shortcode and the next {{% %}}

Abierto Apto para principiantes
#293 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

@Ashborne-lab ya está trabajando en esto.

Desde el 14/11/2026.

  • #294 de @Ashborne-lab — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
70/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
data

Línea de trabajo

El error está en HUGO_SHORTCODE_RE en docs-agent-mcp/pipelines/utils/canonical_rag_ingest.py, usado por _strip_hugo_artifacts(). Ejecuta el fragmento de reproducción del issue: debería imprimir 'A keep this B' en lugar de 'A B'. Está terminado cuando la alternativa de shortcode {{< deja de coincidir con texto hasta un %}} posterior, y una prueba cubre el texto entre un shortcode de corchete angular y uno de porcentaje.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Area

pipelines

What happened

HUGO_SHORTCODE_RE in docs-agent-mcp/pipelines/utils/canonical_rag_ingest.py is

re.compile(r"\{\{.*?%\}\}|\{\{.*?\}\}", re.DOTALL)

The first alternative can start at any {{, not only at {{%. When the parser reaches an angle-bracket shortcode such as {{< figure ... >}}, that alternative matches lazily forward to the next %}} anywhere later in the page, and _strip_hugo_artifacts() deletes everything in between, before the document is split into sections and chunks.

On the current kubeflow/website content (commit a7b22c9), running every page through parse_canonical_document() with the current regex and with a fixed one shows text lost on 5 pages (970 characters in total). The largest case is content/en/docs/started/installing-kubeflow/index.md, which loses the rows for five packaged distributions (prokube.ai, Microsoft Azure, Nutanix, QBO and Red Hat). Those vendors never reach the index, so the assistant cannot answer "is there a Kubeflow distribution for Azure / Red Hat / Nutanix?" from the docs. The other four pages are API reference pages that lose their spec link text.

Expected behavior

Only the shortcodes themselves are removed. Text between two shortcodes is kept.

Reproduction

From the repo root:

import sys
sys.path.insert(0, "docs-agent-mcp/pipelines/utils")
from canonical_rag_ingest import _strip_hugo_artifacts

print(repr(_strip_hugo_artifacts(
    'A {{< figure src="/a.png" >}} keep this {{% kf-latest-version %}} B'
)))

Output on main (145409a): 'A B'
Expected: 'A keep this B'

Environment: local, Python 3.12, no cluster needed.

Suspected files

docs-agent-mcp/pipelines/utils/canonical_rag_ingest.py (HUGO_SHORTCODE_RE, _strip_hugo_artifacts)

I have a fix with tests ready and will open a PR.

Lenguaje dominante
Python
Estrellas
49
Forks
122
Merge medio
10 h 54 min
PR fusionados (30 d)
2

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de kubeflow/docs-agent

Todos los issues de kubeflow/docs-agent

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.