Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

firestore: field path with a quoted name ending in a backslash is misparsed

Abierto Apto para principiantes
#18,771 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@sebxt ya está trabajando en esto.

Desde el 19/10/2026.

  • #18772 de @sebxt — abierto

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
Activo
Stack tecnológico
python

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

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 googleapis/google-cloud-python

Todos los issues de googleapis/google-cloud-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.