Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong allOf behaviour #2923

Open
4 tasks done
AlimovSV opened this issue Jul 12, 2022 · 6 comments · Fixed by #3227
Open
4 tasks done

Wrong allOf behaviour #2923

AlimovSV opened this issue Jul 12, 2022 · 6 comments · Fixed by #3227
Assignees
Labels
any-one-all-of Related to fixing anyOf, oneOf or allOf bug help wanted

Comments

@AlimovSV
Copy link

AlimovSV commented Jul 12, 2022

Prerequisites

What theme are you using?

core

Version

4.2.0

Current Behavior

Expected Behavior

Should be valid

Steps To Reproduce

Example

Schema

{
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "allOf": [
        {
          "contains": {
            "required": [
              "value"
            ],
            "type": "object",
            "properties": {
              "value": {
                "pattern": "456"
              }
            }
          }
        },
        {
          "contains": {
            "required": [
              "value"
            ],
            "type": "object",
            "properties": {
              "value": {
                "pattern": "123"
              }
            }
          }
        }
      ],
      "items": {
        "type": "object",
        "required": [
          "value"
        ],
        "properties": {
          "value": {
            "enum": [
              "123",
              "456",
              "789"
            ],
            "type": "string"
          }
        }
      }
    }
  }
}

Data

{
  "data": [
    {
      "value": "123"
    },
    {
      "value": "456"
    }
  ]
}

Environment

- OS: any
- Node: any
- npm: any

Anything else?

  • The problem is caused by jsonschema-merge-allof that is merging allOf values into the schema:
      "contains": {
        "required": [
          "value"
        ],
        "type": "object",
        "properties": {
          "value": {
            "allOf": [
              {
                "pattern": "123"
              },
              {
                "pattern": "456"
              }
            ]
          }
        }
      }
  • This example was workable before this PR was merged. But I guess this PR just unmasked the issue.
@AlimovSV AlimovSV added bug needs triage Initial label given, to be assigned correct labels and assigned labels Jul 12, 2022
@AlimovSV
Copy link
Author

I tried to upgrade jsonschema-merge-allof to the latest version, but the result is similar, the retrieved schema contains:

      "contains": {
        "required": [
          "type"
        ],
        "type": "object",
        "properties": {
          "type": {
            "pattern": "(?=45e83143-f0f2-401b-b530-5965157d8e57)(?=52ea35ac-d8a0-4d6e-99b3-ee9a677c5579)"
          }
        }
      },

which is completely wrong. The logic is "data should contain {type:'123'} AND {type:'456'} items", not "data should contain item where type equal to 123 and 456"

@heath-freenome heath-freenome added the any-one-all-of Related to fixing anyOf, oneOf or allOf label Sep 29, 2022
@heath-freenome heath-freenome removed the needs triage Initial label given, to be assigned correct labels and assigned label Dec 9, 2022
nickgros added a commit that referenced this issue Dec 22, 2022
Co-authored-by: Sergey Alimov <sergey.alimov@gmail.com>
Co-authored-by: Heath C <51679588+heath-freenome@users.noreply.github.com>
Fixes #2923
shijistar pushed a commit to shijistar/react-jsonschema-form that referenced this issue Jun 8, 2023
…am#3025) (rjsf-team#3227)

Co-authored-by: Sergey Alimov <sergey.alimov@gmail.com>
Co-authored-by: Heath C <51679588+heath-freenome@users.noreply.github.com>
Fixes rjsf-team#2923
shijistar pushed a commit to shijistar/react-jsonschema-form that referenced this issue Jun 8, 2023
…am#3025) (rjsf-team#3227)

Co-authored-by: Sergey Alimov <sergey.alimov@gmail.com>
Co-authored-by: Heath C <51679588+heath-freenome@users.noreply.github.com>
Fixes rjsf-team#2923
@AlimovSV
Copy link
Author

AlimovSV commented Feb 15, 2024

Looks like we have some regression from 4.2 to 5.xx for this case. Schema is valid, data matches to the schema, but RJSF@5 says that every item is wrong. I remember @nickgros fixed this issue for 4.2 and this works on the old project. But after upgrading to 5.x i faced with this issue again.

@nickgros
Copy link
Contributor

@AlimovSV Thanks for the reproduction link, I'll reopen this

@nickgros nickgros reopened this Feb 16, 2024
@nickgros nickgros added the needs triage Initial label given, to be assigned correct labels and assigned label Feb 16, 2024
@nickgros nickgros added help wanted and removed needs triage Initial label given, to be assigned correct labels and assigned labels Mar 1, 2024
@AlimovSV
Copy link
Author

Any updates?

@heath-freenome
Copy link
Member

@AlimovSV We are looking for help in fixing this. Is this something you feel comfortable doing?

@AlimovSV
Copy link
Author

@heath-freenome Thank you! At the moment I have to use v4.2 and freeze any upgrades.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
any-one-all-of Related to fixing anyOf, oneOf or allOf bug help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants