Scope through a property whose name ends in "then" or "else" binds the control to the wrong data path
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- react, typescript
調査の方向性
issueで誤ったパスの原因としてtoDataPath内の正規表現が指摘されているため、まずpackages/core/src/util/path.tsを確認します。パス変換の既存テストを調べ、then、else、something_elseという名前のプロパティと、キーワード全体からなるセグメントのテストを追加します。プロパティのセグメントが保持され、スキーマのキーワードセグメントは引き続き削除され、報告されたパスがsomething_else.nameになることを完了条件とします。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
toDataPathSegments strips then/ and else/ (and anyOf/N/ etc.) anywhere in the scope string, not only as whole path segments. So a scope that goes through a property named then, else, something_else, strengthen, ... is turned into a wrong data path:
import { toDataPath } from "@jsonforms/core";
toDataPath("#/properties/something_else/properties/name"); // "something_properties"
toDataPath("#/properties/then/properties/name"); // "properties"
toDataPath("#/properties/strengthen/properties/x"); // "strengproperties"
In a form the control shows nothing and typing writes to a new top-level key. With the React vanilla renderers, data { something_else: { name: "Bob" } } shows an empty input, and typing "Alice" produces
{"something_else":{"name":"Bob"},"something_properties":"Alice"}
Rules whose condition scope goes through such a property read the wrong value too.
Expected behavior
toDataPath("#/properties/something_else/properties/name") is "something_else.name", the input shows "Bob", and typing gives {"something_else":{"name":"Alice"}}. Only whole then/else segments (as in #/then/properties/x) should be dropped.
Steps to reproduce the issue
import { JsonForms } from "@jsonforms/react";
import { vanillaRenderers, vanillaCells } from "@jsonforms/vanilla-renderers";
const schema = {
type: "object",
properties: {
something_else: { type: "object", properties: { name: { type: "string" } } },
},
};
const uischema = {
type: "VerticalLayout",
elements: [{ type: "Control", scope: "#/properties/something_else/properties/name" }],
};
<JsonForms
schema={schema}
uischema={uischema}
data={{ something_else: { name: "Bob" } }}
renderers={vanillaRenderers}
cells={vanillaCells}
onChange={({ data }) => console.log(JSON.stringify(data))}
/>;
- Render the form: the input is empty instead of "Bob".
- Type "Alice":
onChangelogs{"something_else":{"name":"Bob"},"something_properties":"Alice"}.
With a property named name2 instead, the same form works.
Screenshots
No response
Which Version of JSON Forms are you using?
v3.8.0 (also master 942b76f)
Package
Core
Additional context
The regexes in packages/core/src/util/path.ts are /(anyOf|allOf|oneOf)\/[\d]+\//g and /(then|else)\//g. They match inside a segment, and they also match a segment that is a property name, so the scope would need to be split into segments first and then/else/anyOf/N dropped only where a keyword is expected (not right after properties).
Credit: https://ucsbplse.github.io/
- 主要言語
- TypeScript
- スター
- 2.8k
- フォーク
- 423
- 平均マージ
- 5日 16時間
- マージ済み PR(30日)
- 9
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
eclipsesource/jsonforms のほかの issue
-
Add "append" and "prepend" slots for vue-vuetify extended renderers対応中かも @simeyc が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
eclipsesource/jsonforms#2668 ·
メンテナーはふだん 1 日以内に返信
-
angular material
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
eclipsesource/jsonforms#2662 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
core
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
eclipsesource/jsonforms#2570 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
dev
難易度 2/5 1〜3時間 初心者へのやさしさ 50/100
eclipsesource/jsonforms#2651 ·
メンテナーはふだん 1 日以内に返信
-
angular material
難易度 4/5 3〜5日 初心者へのやさしさ 68/100
eclipsesource/jsonforms#2630 ·
メンテナーはふだん 1 日以内に返信
eclipsesource/jsonforms の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
README の通知条件を実際の判定処理に合わせる対応中かも @unhappychoice が今日担当しました。 オープンfactory:in-progress priority:medium
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
unhappychoice/oss-issue-opener#395 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug Website
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
OWASP/OWASP-Hunting#88 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信