firestore: field path with a quoted name ending in a backslash is misparsed
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 78/100
Direção de pesquisa
Comece por google/cloud/firestore_v1/field_path.py e inspecione o padrão do token QUOTED usado por FieldPath.from_api_repr(); reproduza a falha com o exemplo de FieldPath fornecido. Confira os testes do parser de caminhos de campo e adicione cobertura para um segmento entre aspas que termina com uma barra invertida, seguido por outro segmento. A tarefa estará concluída quando a representação da API for analisada de volta para as partes originais e a atualização atingir o campo aninhado descrito na issue.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Python
- Estrelas
- 5.4k
- Forks
- 1.8k
- Merge médio
- 2d 1h
- PRs com merge (30d)
- 191
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de googleapis/google-cloud-python
-
api: spanner type: feature request
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
googleapis/google-cloud-python#18584 ·
Mantenedores costumam responder em até 1 dia
-
auth: call_client_cert_callback() discards passphrase for encrypted keysTalvez já em andamento @kwy404 assumiu há 18 dias. Aberta
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 92/100
googleapis/google-cloud-python#18467 ·
Mantenedores costumam responder em até 1 dia
-
auth: `impersonated_credentials` loses `subject` on copy, so `with_scopes()` and `with_quota_project()` turn off domain wide delegationTalvez já em andamento @Om-singhaI assumiu há 30 dias. Abertaauth priority: p2 type: bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
googleapis/google-cloud-python#18428 ·
Mantenedores costumam responder em até 1 dia
-
priority: p2 type: bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
googleapis/google-cloud-python#18375 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
ci: enable --strict flag in presubmit twine_checkTalvez já em andamento @ohmayr assumiu há 19 dias. Aberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 76/100
googleapis/google-cloud-python#18339 · 1 comentário · 1 responsável ·
Mantenedores costumam responder em até 1 dia
Todas as issues de googleapis/google-cloud-python
Issues semelhantes
-
good first issue tools
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
bug deferred domain:ci P1
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Mantenedores costumam responder em até 1 dia
-
get_page_thumbnail modifies cached page images, affecting later thumbnails and picture exportsAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
docling-project/docling-mcp#147 ·
-
issue: A pipe model's Valves button ignores the Allow Chat Valves permissionTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Abertabug confirmed issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
open-webui/open-webui#32771 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Scheduled Security Scan is failing on mainTalvez já em andamento @pkupt assumiu hoje. Abertasecurity-scan-failure
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 74/100
semantica-agi/semantica#2045 ·
Mantenedores costumam responder em até 2 dias