get_unique_name appends to the previous candidate name when a collision triggers a retry
Los mantenedores suelen responder en 4 días
@rahul05ranjan ya está trabajando en esto.
Desde el 28/10/2026.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 35/100
Línea de trabajo
Start in the implementation of fsutil.get_unique_name() and inspect how the candidate name is built before the exists() check. The issue suggests reproducing the collision with sequential UUIDs and checking that a retry builds a fresh candidate; the suggested regression test can verify the second name. Two linked pull requests are already open.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
fsutil.get_unique_name() builds the candidate name with += while the name is initialized to "" outside the retry loop:
name = ""
while True:
if prefix:
name += f"{prefix}{separator}"
uid = uuid.uuid4()
name += f"{uid}"
...
if exists(join_path(path, name)):
continue
break
When the exists() check finds a collision and continues, the candidate is not rebuilt from scratch: the next prefix/uuid/suffix/extension are appended onto the previous (already colliding) candidate, producing a garbage name like:
prefix-<uid1>-suffix.txtprefix-<uid2>-suffix.txt
instead of
prefix-<uid2>-suffix.txt
This is hard to hit with random uuid4 values, but the loop exists precisely to handle collisions (e.g. when a caller passes a monkeypatched/sequential uuid source, or get_unique_name is reused as a generic "find unused name" helper by replace_dir / replace_file which rely on it for safe temporary names).
Suggested fix
Move name = "" inside the while True: loop so every retry starts clean. Adding a regression test is easy by monkeypatching fsutil.paths.uuid.uuid4 to a sequential iterator and creating the first candidate on disk before the second call.
Happy to send a PR.
- Lenguaje dominante
- Python
- Estrellas
- 268
- Forks
- 25
- Merge medio
- 4 d 11 h
- PR fusionados (30 d)
- 2
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de fabiocaccamo/python-fsutil
-
download_file ignores the RFC 6266 filename* Content-Disposition parameterPosiblemente ocupada @rahul05ranjan la tomó hace 7 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
fabiocaccamo/python-fsutil#208 ·
Los mantenedores suelen responder en 4 días
-
Atomic append fails to create a missing filePosiblemente ocupada @harbinresearcher la tomó hace 21 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
fabiocaccamo/python-fsutil#201 ·
Los mantenedores suelen responder en 4 días
-
Add `toml` files operation support.Quizá libre de nuevo @fabiocaccamo la tomó hace 1342 días y no hay ningún pull request abierto. Abiertoenhancement
fabiocaccamo/python-fsutil#42 · 1 asignado ·
Los mantenedores suelen responder en 4 días
Todos los issues de fabiocaccamo/python-fsutil
Issues similares
-
needs-area-label
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 2 días
-
enhancement good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Official-Space-AI/OpenPhysGraspGen#114 ·
Los mantenedores suelen responder en 2 días
-
changelog investigate
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
ramnes/notion-sdk-py#441 ·
-
qa_bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
NVIDIA-NeMo/Gym#5644 ·
Los mantenedores suelen responder en 2 días
-
BUG: catalog database credentials printed to logs at startupPosiblemente ocupada @cjboyle la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día