base-output-filename: duplicate names silently overwrite outputs; dotted names are truncated

Abierto
#87 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python
Área
tooling

Línea de trabajo

Start in ogc/bblocks/validate.py, tracing the output_base_filenames collision guard, sanitize_filename, and with_suffix usage; then read the base-output-filename definition in examples.schema.yaml. Check how outputs from examples, snippets, tests/, and extra test resources are named. Done means the chosen duplicate and dotted-name behavior is implemented consistently, covered by tests, and described in the schema.

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

Descripción

While documenting base-output-filename for the authoring skills, I traced how it is used in ogc/bblocks/validate.py and found some gaps. The field is defined per example in examples.schema.yaml. The default when it is unset is example_<n>_<m>.<ext>, and the value drives the snippet copy, .jsonld, .ttl, .validation_*.txt and transform outputs.

1. Duplicate names silently overwrite each other

The collision guard in validate.py (while output_fn.stem in output_base_filenames: ... with_stem(f"{stem}-{i}")) only protects against clashes with files from tests/ and extra test resources, because output_base_filenames is populated only from those. Example outputs are never added to it, so:

  • Two examples with the same base-output-filename overwrite each other's outputs, with no warning and no error.
  • Snippets in the same example share the example's base name. Snippets with different languages differ only by extension, so their .jsonld, .ttl and .validation_*.txt outputs collide. Snippets with the same language overwrite each other completely.

The same happens if the name is copy-pasted between examples, which is easy to do when adding a new one.

2. Dotted names lose their last segment

The value goes through sanitize_filename(...) and then .with_suffix(f'.{extension}'). with_suffix replaces the last suffix, so my.feature becomes my.<ext>. The schema text ("Extension, if any, will be discarded") is intentional for my-feature.json, but it can't distinguish that from a dotted name that isn't an extension (versions, v1.2-example, etc.).

Possible fixes

  • Track example outputs in output_base_filenames too, so the existing -1, -2 disambiguation applies to them, or fail/warn on a duplicate base-output-filename.
  • Disambiguate snippets within one example (for example by appending the snippet index when the example has more than one snippet).
  • Append the extension instead of using with_suffix, and strip only known extensions. Or document that dots are not allowed.
  • Whichever behavior is chosen, mention it in the schema description for base-output-filename.

Found against local checkout at commit 6411aed. The line numbers may differ upstream.

Lenguaje dominante
Python
Estrellas
1
Forks
6
Merge medio
23 h 43 min
PR fusionados (30 d)
7

Preparar el entorno

  • Incluye un Dockerfile o un archivo de Docker Compose
  • Sin plantilla de pull request
  • Sin guía de contribución

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 opengeospatial/bblocks-postprocess

Todos los issues de opengeospatial/bblocks-postprocess

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.