Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン 初心者向け
#18,771 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@auraseb がすでに取り組んでいます。

2026年10月19日 から。

  • #18772 @auraseb による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
backend, databases

調査の方向性

まず google/cloud/firestore_v1/field_path.py を確認し、FieldPath.from_api_repr() で使われている QUOTED トークンパターンを調べます。提示された FieldPath の例で不具合を再現してください。フィールドパスパーサーのテストを確認し、バックスラッシュで終わる引用符付きセグメントの後に別のセグメントが続くケースのテストを追加してください。API 表現を解析すると元の各パーツに戻り、更新が Issue に記載されたネストされたフィールドを対象にすれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
5.4k
フォーク
1.8k
平均マージ
2日 1時間
マージ済み PR(30日)
191

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

googleapis/google-cloud-python のほかの issue

googleapis/google-cloud-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。