Skip to content

Conversation

@reithor
Copy link
Contributor

@reithor reithor commented Oct 28, 2025

PR adds enhanced exception handling to contentCreate
(ContentFieldValidationException::createNewWithMultiline($errors) was introduced in ezsystems/ezplatform-kernel#329)

Without PR, thrown errors will show up as :

Content fields did not validate

With PR, details regarding affected fields will be shown:

  Content "" fields did not validate:
  - Value for required field definition 'short_name' with language 'eng-GB' is empty
  - ...

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 5, 2025

Copy link
Member

@alongosz alongosz left a comment

Choose a reason for hiding this comment

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

The reason we didn't push for this change here and in the other places was BC concern. As you can see yourself, the matching pattern of a message slightly changes. It's likely that UI translations would require regenerating (there's no test for that due to technical challenges).

I'm not saying no. After all it's an improvement and BC concern touches mostly both 1st party (easy to check) and 3rd party E2E coverage.

However, what are the implications for the UI? Meaning how does this show up in the interface?

{
$this->expectException(ContentFieldValidationException::class);
$this->expectExceptionMessage('Content fields did not validate');
$this->expectExceptionMessage('Content "" fields did not validate');
Copy link
Member

Choose a reason for hiding this comment

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

This is concerning. Is there no content name at this stage due to business logic or mocking?

Side note: this code is most likely a result of few automated refactoring. If you're touching this, both expectException and expectExceptionMessage should be moved right before the statement which produces the exception.

Copy link
Contributor Author

@reithor reithor Nov 5, 2025

Choose a reason for hiding this comment

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

However, what are the implications for the UI? Meaning how does this show up in the interface?

I don't think it is shown in the UI at all.
Error is thrown when creating content

# [src/lib/Repository/ContentService->createContent()

        $errors = $this->validate(
            $contentCreateStruct,
            [],
            $fieldIdentifiersToValidate
        );

        if (!empty($errors)) {
-            throw new ContentFieldValidationException($errors);
+           throw ContentFieldValidationException::createNewWithMultiline($errors);
        }

At this stage we only have $contentCreateStruct - nothing is persisted - we do not have a ContentName yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But I see the BC concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants