Bug - JMESPath `*` vs `[*]` semantics

オープン
#65 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
rust
領域
compilers

調査の方向性

ドット付きプロジェクションを処理する parser から始め、.[*] と [*].[*] に対して生成される AST を調べます。これらのノードを、issue で説明されている単独の * と [*] のケースと比較し、その後、記載されているオブジェクトおよび配列の評価結果に対して修正後の動作を検証します。ドット付きリストワイルドカードが期待されるプロジェクション AST と実行時結果を生成すれば完了です。

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

説明

bug

Per the JMESPath specification, * (hash wildcard) and [*] (list wildcard) are never interchangeable:

Expression On object On array On wrong type
* Returns values as list null null
[*] null Returns elements as list null
AST structure in jmespath 0.5.0

The two operators produce distinct AST nodes:

  • * → Projection { lhs: ObjectValues(Identity), rhs } → dispatched to visit_wildcard_projection
  • [*] → Projection { lhs: Identity, rhs } → dispatched to visit_projection
.[*] is broken in jmespath 0.5.0

The primary example in this issue (*.[*] | [?status == 'active']) uses .[*] (dotted list wildcard). This construct is broken at the parser level in jmespath 0.5.0:

Expected AST for .[*]: Projection { lhs: Identity, rhs: Identity } (same as standalone [*])

Actual AST: MultiList([Projection { lhs: ObjectValues(Identity), rhs: Identity }]) — a multi-select list wrapping a hash wildcard, not a list wildcard.

Runtime verification:

           *  on {"a":[1,2],"b":[3,4]}  => [[1,2],[3,4]]     ✓
         [*]  on {"a":[1,2],"b":[3,4]}  => null               ✓ (spec: [*] on object → null)
       *.[*]  on {"a":[1,2],"b":[3,4]}  => [[null],[null]]    ✗ (expected [[1,2],[3,4]])
         [*]  on [[1,2],[3,4]]           => [[1,2],[3,4]]      ✓
     [*].[*]  on [[1,2],[3,4]]           => [[null],[null]]    ✗ (expected [[1,2],[3,4]])

The .[*] construct produces null for each projected value because the parser represents it as a hash wildcard (*) applied to arrays, which returns null per the JMESPath spec.

主要言語
Rust
スター
162
フォーク
37
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

jmespath/jmespath.rs のほかの issue

jmespath/jmespath.rs の issue をすべて見る

似ている issue

Rust の issue をもっと見る

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

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