Scope through a property whose name ends in "then" or "else" binds the control to the wrong data path
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 78/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- react, typescript
- Domaine
- backend-api-design, frontend
Piste de recherche
Commencez par packages/core/src/util/path.ts, où l’issue identifie les expressions régulières de toDataPath comme la source du chemin incorrect. Examinez les tests existants de conversion de chemins et ajoutez une couverture pour les propriétés nommées then, else ou something_else, ainsi que pour les segments constitués de mots-clés entiers. Le travail est terminé lorsque les segments de propriété sont conservés tandis que les segments de mots-clés du schéma sont toujours supprimés, de sorte que le chemin signalé devienne something_else.name.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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/
- Langage dominant
- TypeScript
- Étoiles
- 2.8k
- Forks
- 423
- Merge moyen
- 5 j 16 h
- PR mergées (30 j)
- 9
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de eclipsesource/jsonforms
-
Add "append" and "prepend" slots for vue-vuetify extended renderersPeut-être pris @simeyc l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
eclipsesource/jsonforms#2668 ·
Les mainteneurs répondent en général sous 1 jour
-
angular material
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
eclipsesource/jsonforms#2662 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
core
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
eclipsesource/jsonforms#2570 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
dev
Difficulté 2/5 1-3 heures Accessibilité débutants 50/100
eclipsesource/jsonforms#2651 ·
Les mainteneurs répondent en général sous 1 jour
-
angular: propagate the enabled state to detail renderers instead of modifying their UI schemaOuverteangular material
Difficulté 4/5 3-5 jours Accessibilité débutants 68/100
eclipsesource/jsonforms#2630 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de eclipsesource/jsonforms
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour
-
README の通知条件を実際の判定処理に合わせるPeut-être pris @unhappychoice l’a pris aujourd’hui. Ouvertefactory:in-progress priority:medium
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
unhappychoice/oss-issue-opener#395 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
bug Website
Difficulté 2/5 1-3 heures Accessibilité débutants 77/100
OWASP/OWASP-Hunting#88 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour