Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#18,771 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@auraseb ci sta già lavorando.

Dal 19/10/2026.

  • #18772 di @auraseb — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend, databases

Direzione di ricerca

Inizia da google/cloud/firestore_v1/field_path.py e analizza il pattern del token QUOTED usato da FieldPath.from_api_repr(); riproduci il problema con l’esempio FieldPath fornito. Controlla i test del parser dei percorsi dei campi e aggiungi copertura per un segmento tra virgolette che termina con una barra rovesciata, seguito da un altro segmento. Il lavoro è completato quando la rappresentazione API viene analizzata di nuovo ottenendo le parti originali e l’aggiornamento punta al campo annidato descritto nell’issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
5.4k
Fork
1.8k
Merge medio
2g 1h
PR unite (30g)
191

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di googleapis/google-cloud-python

Tutte le issue di googleapis/google-cloud-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.