firestore: field path with a quoted name ending in a backslash is misparsed
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
調査の方向性
まず 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
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
googleapis/google-cloud-python のほかの issue
-
api: spanner type: feature request
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
googleapis/google-cloud-python#18584 ·
メンテナーはふだん 1 日以内に返信
-
auth: call_client_cert_callback() discards passphrase for encrypted keys対応中かも @kwy404 が 18 日前に担当しました。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 92/100
googleapis/google-cloud-python#18467 ·
メンテナーはふだん 1 日以内に返信
-
auth: `impersonated_credentials` loses `subject` on copy, so `with_scopes()` and `with_quota_project()` turn off domain wide delegation対応中かも @Om-singhaI が 30 日前に担当しました。 オープンauth priority: p2 type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
googleapis/google-cloud-python#18428 ·
メンテナーはふだん 1 日以内に返信
-
priority: p2 type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
googleapis/google-cloud-python#18375 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
ci: enable --strict flag in presubmit twine_check対応中かも @ohmayr が 19 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 76/100
googleapis/google-cloud-python#18339 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
googleapis/google-cloud-python の issue をすべて見る
似ている issue
-
wr.dynamodb.read_items returns [{}] for a single partition value that does not exist対応中かも @auraseb が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
aws/aws-sdk-pandas#3520 ·
メンテナーはふだん 2 日以内に返信
-
requires triage typing
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
sqlalchemy/sqlalchemy#13704 ·
メンテナーはふだん 1 日以内に返信
-
Edit tool converts CRLF files to LF対応中かも @RaphaelFakhri が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
huggingface/tau#774 ·
メンテナーはふだん 1 日以内に返信
-
show ignores the row limit when a column or table name contains "limit"対応中かも @RaphaelFakhri が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
linebender/resvg#1179 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信