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

Fix Rich text block validation path #18578

Merged
merged 2 commits into from
Mar 5, 2025

Conversation

Migaroez
Copy link
Contributor

@Migaroez Migaroez commented Mar 5, 2025

Description

The base implementation of the block validator does not take into account that the actual implementation can wrap its content/settings data in another object.
This causes issues with the jsonpath returned in validation messages not matching with the actual property path.

To fix this, the hardcoded mapping was moved into a get only overridable string.

The RTE block validator can now signal the correct path to the base class with an override.

Testing

Ask Niels 😅
Or setup a doctype with a blocklist/grid and an RTE using the same element doctype that has properties with validation that fails on the backend. Create the node add a block to each property => Save and publish => the validate endpoint should return a jsonpath for the invalid properties in the RTE block that starts with $...value.blocks.contentData... instead of $...value.contentData...

@Migaroez Migaroez changed the base branch from contrib to release/15.3 March 5, 2025 09:58
Copy link
Contributor

@AndyButland AndyButland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this locally and can confirm the API response for the validation path looks as expected.

For the rich text editor, before the PR - i.e. with release/15.3 - the invalid response for a block in an RTE is (which is the same as for a block list):

{
  "type": "Error",
  "title": "Validation failed",
  "status": 400,
  "detail": "One or more properties did not pass validation",
  "operationStatus": "PropertyValidationError",
  "errors": {
    "$.values[0].value.contentData[0].values[0].value": [
      "#validation_invalidEmpty"
    ]
  }
}

With the PR in place we get:

{
  "type": "Error",
  "title": "Validation failed",
  "status": 400,
  "detail": "One or more properties did not pass validation",
  "operationStatus": "PropertyValidationError",
  "errors": {
    "$.values[0].value.blocks.contentData[0].values[0].value": [
      "#validation_invalidEmpty"
    ]
  }
}

@nielslyngsoe
Copy link
Member

@Migaroez thanks, works much better now. I approve.

@nielslyngsoe nielslyngsoe merged commit 0cead6f into release/15.3 Mar 5, 2025
21 checks passed
@nielslyngsoe nielslyngsoe deleted the v15/hotfix/block-validation-path branch March 5, 2025 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants