Concurrent project renames can nest projects and mix files on push

Abierto
#780 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
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
cli

Línea de trabajo

Start in the project manager that implements get_local_project_path and rename_project_and_contents, and follow how PushManager._push_project and _push_metadata use the returned destination. Reproduce the interleaving in a test using a temporary filesystem, then make destination claiming reject an already-occupied target and reselect instead of relying on shutil.move. Done means both main.py files stay in separate sibling trees and get_source_files on each destination returns only its own file.

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

Descripción

priority:P2

Problem

Destination selection and project renaming are not atomic. Two pushes in the same workspace can select the same currently free sanitized name. If one moves first, the other shutil.move nests its source inside the now-existing destination rather than rejecting the collision. Source enumeration then includes both projects' files.

Reproduction and evidence

Reproduced on master at 508863e using real project/configuration managers and a temporary filesystem, with the two operations deliberately interleaved:

  1. Create Race@Project with cloud ID 1 and main.py containing # SOURCE 1.
  2. Create Race#Project with cloud ID 2 and main.py containing # SOURCE 2.
  3. Resolve both destinations before moving either:
    first_destination = manager.get_local_project_path(first.name, cloud_id=1, source_path=first)
    second_destination = manager.get_local_project_path(second.name, cloud_id=2, source_path=second)
    
    Both return the nonexistent Race Project directory.
  4. Call rename_project_and_contents(first, first_destination), then rename_project_and_contents(second, second_destination).
  5. Both moves return successfully. The second project is now Race Project/Race#Project, not a separate sibling.
  6. get_source_files(second_destination) returns both:
    • main.py: # SOURCE 1
    • Race#Project/main.py: # SOURCE 2

PushManager._push_project resumes at the selected destination after its rename; _push_metadata reads the files there. The interleaving therefore makes the second push consume the first project's root files as well as the nested second project's files.

Expected result

A destination that becomes occupied between lookup and rename must not cause nesting or selection of another project's files. Preserve both source trees and keep their upload inputs separate. Add a regression covering the interleaving above.

Suggestion: make destination claiming/moving reject an occupied target and retry selection, rather than relying on shutil.move's directory-container behavior.

This requires overlapping renames in the same workspace. Serializing pushes is a workaround.

Lenguaje dominante
Python
Estrellas
335
Forks
172
Merge medio
6 h 54 min
PR fusionados (30 d)
37

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

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 QuantConnect/lean-cli

Todos los issues de QuantConnect/lean-cli

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.