firestore: field path with a quoted name ending in a backslash is misparsed
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
Línea de trabajo
Empieza por google/cloud/firestore_v1/field_path.py e inspecciona el patrón del token QUOTED que usa FieldPath.from_api_repr(); reproduce el fallo con el ejemplo de FieldPath proporcionado. Revisa las pruebas del analizador de rutas de campos y añade cobertura para un segmento entrecomillado que termina en una barra invertida seguida de otro segmento. La tarea estará terminada cuando la representación de la API se vuelva a analizar y produzca las partes originales, y la actualización apunte al campo anidado descrito en el issue.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Package: google-cloud-firestore (google/cloud/firestore_v1/field_path.py), current main.
What happens
FieldPath.to_api_repr() escapes a trailing backslash correctly, but the parser cannot read the result back when another quoted segment follows it. FieldPath.from_api_repr() raises ValueError, and FieldPath.from_string() catches that error and falls back to a plain split on ., so it silently returns parts that still contain the backticks and escape characters.
Because update() and set(..., merge=[...]) go through FieldPath.from_string() / parse_field_path(), the write goes to the wrong field.
Minimal repro
from google.cloud.firestore_v1.field_path import FieldPath
from google.cloud.firestore_v1 import _helpers
s = FieldPath("dir\\", "file name").to_api_repr()
print(s) # `dir\\`.`file name`
print(FieldPath.from_string(s).parts) # ('`dir\\\\`', '`file name`')
FieldPath.from_api_repr(s) # ValueError: Invalid path
pbs = _helpers.pbs_for_update("projects/p/databases/d/documents/c/doc", {s: 1}, None)
print(list(pbs[0].update.fields)) # ['`dir\\\\`']
What should happen
The string produced by to_api_repr() should parse back to the same parts, ('dir\\', 'file name'), and the update should target dir\ > file name.
Root cause
The QUOTED token pattern is r"`(?:\\`|[^`])*?`". In `dir\\`.`file name` the lazy match takes the second backslash together with the closing backtick as an escaped backtick (\`), so the token runs on to the next backtick and swallows `.`. What remains (file name`) does not tokenize, so parsing fails. The pattern needs to treat a backslash as an escape for the next character, not only for a backtick, and should not let a bare backslash match on its own.
- Lenguaje dominante
- Python
- Estrellas
- 5.4k
- Forks
- 1.8k
- Merge medio
- 1 d 21 h
- PR fusionados (30 d)
- 200
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la 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 googleapis/google-cloud-python
-
api: spanner type: feature request
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
googleapis/google-cloud-python#18584 ·
Los mantenedores suelen responder en 1 día
-
auth: `impersonated_credentials` loses `subject` on copy, so `with_scopes()` and `with_quota_project()` turn off domain wide delegationPosiblemente ocupada @Om-singhaI la tomó hace 31 días. Abiertoauth priority: p2 type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
googleapis/google-cloud-python#18428 ·
Los mantenedores suelen responder en 1 día
-
priority: p2 type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
googleapis/google-cloud-python#18375 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
ci: enable --strict flag in presubmit twine_checkPosiblemente ocupada @ohmayr la tomó hace 20 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 76/100
googleapis/google-cloud-python#18339 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
auth: AsyncAuthorizedSession.request leaks response across retry attemptsPosiblemente ocupada @Sanjays2402 la tomó hace 41 días. Abiertoauth priority: p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
googleapis/google-cloud-python#18315 ·
Los mantenedores suelen responder en 1 día
Todos los issues de googleapis/google-cloud-python
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 80/100
521xueweihan/HelloGitHub#4063 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Vanilla-OS/apx-gui#112 ·
-
Devstral and Voxtral: section 5 fails in us-east-1 with 400 "Model does not support audio modality"Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
aws-samples/sample-per-model-bedrock#409 ·
Los mantenedores suelen responder en 1 día
-
DuckDB 2.0 breaks to_pyarrow_batchesPosiblemente ocupada @DG47 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
ibis-project/ibis#12196 ·
Los mantenedores suelen responder en 1 día