Companion/extra-waypoint GPX imported without matching cache silently produces zero results, no warning

Abierto Apto para principiantes
#648 0 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
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Tranquilo
Stack tecnológico
python
Área
data

Línea de trabajo

Empieza en src/opensak/importer/__init__.py: lee _insert_extra_wpts() y la rama if cache_id is None: continue, y luego el lugar de import_gpx() donde se construye ImportResult. Reproduce el caso con SAMPLE_WPTS_GPX de tests/data.py en una base de datos vacía y confirma que el resultado no tiene advertencias. Está terminado cuando esa importación añade a result.warnings una advertencia que indique cuántos waypoints no tenían un cache coincidente, y un test en los tests del importador lo comprueba.

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

Descripción

area: import improvement
Current State
Background

import_gpx() handles two kinds of GPX <wpt> entries: full geocache
records, and "extra" (child/companion) waypoints belonging to a parent cache
(type="Waypoint|..."). The latter are collected into extra_wpts during
parsing and linked to their parent via _insert_extra_wpts().

If a GPX file contains only extra waypoints — e.g. a companion
xxx-wpts.gpx from a Pocket Query with "Include Additional Waypoints", or
any file imported when its parent cache doesn't yet exist in the active
database — _insert_extra_wpts() silently drops them:

for suffix, wps in wpts_by_suffix.items():
    cache_id = suffix_to_cache_id.get(suffix)
    if cache_id is None:
        continue          # <-- silently discarded, no warning

get_import_type() (utils/utils.py) classifies purely by file extension, so
a companion-only GPX is indistinguishable from a normal cache GPX until
parsing — the user has no way to know which kind of file they picked.

Proposed Improvement
Reproduced

Imported a companion-only GPX (SAMPLE_WPTS_GPX from tests/data.py) into an
empty database:

created=0 updated=0 skipped=0 waypoints=0 errors=[]

No exception, no entry in result.errors, no entry in result.warnings
(the field exists and is already used by the LOC importer, just not here).
The import dialog shows a plain ✅ with all-zero counts — nothing to alert
the user that the file only contained orphaned child waypoints.

Expected Benefits
Expected behavior

When extra_wpts contains waypoints whose suffix has no matching cache,
append a message to result.warnings, e.g.:

"N waypoints found but no matching cache exists in the database.
 Import the main cache GPX first."

so the existing warnings-display path in the import dialog surfaces it
instead of a silent all-zero success.

Where

src/opensak/importer/__init__.py, _insert_extra_wpts() (the
if cache_id is None: continue branch) and the caller in import_gpx()
where ImportResult is assembled.

Lenguaje dominante
Python
Estrellas
37
Forks
17
Merge medio
16 h 7 min
PR fusionados (30 d)
128

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 OpenSAK-Org/OpenSAK

Todos los issues de OpenSAK-Org/OpenSAK

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.