Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[BUG] apm compile reports 'Referenced file not found' for links with a #fragment

Abierto Apto para principiantes
#3,255 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

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

Línea de trabajo

Empieza con validate_link_targets en src/apm_cli/compilation/link_resolver.py y las pruebas del resolvedor de enlaces en tests/unit/compilation/test_link_resolver*.py. Comprueba cómo se resuelven los enlaces relativos con fragmentos y cadenas de consulta; después, ejecuta las pruebas de regresión para los archivos existentes y los que faltan. Se considera terminado cuando los destinos existentes pasan y los destinos que faltan se notifican sin el sufijo.

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

Descripción

Describe the bug
apm compile warns Referenced file not found for a relative Markdown link that carries a fragment, such as [template](references/standards.md#template), even though references/standards.md exists. validate_link_targets in src/apm_cli/compilation/link_resolver.py skips links that start with #, but passes file.md#fragment to _resolve_path unchanged, so the existence check looks for a file literally named standards.md#template. ?query suffixes behave the same.

Skills commonly link to a heading in a reference file, so a skill package with valid links produces one warning per link.

To Reproduce

from pathlib import Path
from apm_cli.compilation.link_resolver import validate_link_targets

base = Path("pkg"); (base / "references").mkdir(parents=True, exist_ok=True)
(base / "references" / "standards.md").write_text("# Template\n")
print(validate_link_targets("[t](references/standards.md#template)", base))
# ["Referenced file not found: references/standards.md#template (in link 't')"]

Or apm install a skill whose SKILL.md links to references/<file>.md#<heading>, then run apm compile --dry-run.

Expected behavior
The fragment (and query) is ignored for the existence check: an existing file passes and a missing file is still reported, without the fragment.

Environment

  • OS: macOS 26 (also expected on Linux and Windows; the check is platform independent)
  • Python Version: 3.12
  • APM Version: 0.33.0 (code unchanged on main)

Additional context
Proposed fix (happy to open a PR once the scope is approved), in validate_link_targets before _resolve_path:

        # Strip a #fragment or ?query: it targets a heading, not a file
        path = re.split(r"[#?]", path, maxsplit=1)[0]

With two regression tests (an existing file with a fragment passes; a missing file with a fragment is reported without it), tests/unit/compilation/test_link_resolver*.py passes (164 tests). resolve_markdown_links has the same startswith("#")-only skip, so a context link with a fragment is not inlined; it may want the same treatment.

Lenguaje dominante
Python
Estrellas
4k
Forks
393
Merge medio
3 d 2 h
PR fusionados (30 d)
102

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 microsoft/apm

Todos los issues de microsoft/apm

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.