Scope through a property whose name ends in "then" or "else" binds the control to the wrong data path
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- react, typescript
- Lĩnh vực
- backend-api-design, frontend
Hướng nghiên cứu
Bắt đầu với packages/core/src/util/path.ts, nơi issue xác định các biểu thức chính quy trong toDataPath là nguyên nhân gây ra đường dẫn không chính xác. Kiểm tra các bài kiểm thử hiện có về chuyển đổi đường dẫn và bổ sung kiểm thử cho các thuộc tính có tên then, else hoặc something_else, cùng với các phân đoạn là từ khóa hoàn chỉnh. Công việc được xem là hoàn tất khi các phân đoạn thuộc tính được giữ nguyên, còn các phân đoạn từ khóa của schema vẫn bị loại bỏ, để đường dẫn được báo cáo trở thành something_else.name.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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/
- Ngôn ngữ chính
- TypeScript
- Star
- 2.8k
- Fork
- 423
- Merge trung bình
- 5 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 9
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của eclipsesource/jsonforms
-
Add "append" and "prepend" slots for vue-vuetify extended renderersCó thể đã có người làm @simeyc đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
eclipsesource/jsonforms#2668 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
angular material
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
eclipsesource/jsonforms#2662 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
core
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
eclipsesource/jsonforms#2570 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
dev
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 50/100
eclipsesource/jsonforms#2651 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
angular: propagate the enabled state to detail renderers instead of modifying their UI schemaĐang mởangular material
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 68/100
eclipsesource/jsonforms#2630 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của eclipsesource/jsonforms
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
README の通知条件を実際の判定処理に合わせるCó thể đã có người làm @unhappychoice đã nhận hôm nay. Đang mởfactory:in-progress priority:medium
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
unhappychoice/oss-issue-opener#395 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug Website
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
OWASP/OWASP-Hunting#88 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày