Skip to content

Conversation

@adamzero1
Copy link
Contributor

@adamzero1 adamzero1 commented Feb 9, 2023

Description (*)

This PR adds more informative output to the existing error message displayed, when there is invalid XML configuration.

For example if there is invalid layout.xml the standard error message displayed to a developer would be something like:

1 exception(s):
Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'arguments': This element is not expected.
Line: 1471

This isn't very helpful as the line number refers to the XML after it has been merged, making it pretty impossible to determine the file that caused the issue.
This PR changes the output to

1 exception(s):
Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'arguments': This element is not expected.
Line: 1471
The xml was: 
1466:            <argument name="show_category" xsi:type="boolean">true</argument>
1467:         </arguments>
1468:      </block>
1469:      <referenceBlock name="product_view_detail" remove="true"/>
1470:      <block name="abc.gtm.product_view_detail" class="ABC\GoogleTagManager\Block\Detail" template="ABC_GoogleTagManager::detailproduct.phtml"/>
1471:      <arguments>
1472:         <argument name="show_category" xsi:type="boolean">true</argument>
1473:      </arguments>
1474:   </referenceContainer>
1475:</body>

Which although the line numbers still refer to the merged XML, it will allow the developer to search the source files for a more specific string. Making it much easier to find the source of the issue.

Related Pull Requests

https://github.com/magento-gl/magento2ee/pull/205

Fixed Issues (if relevant)

N/A

Manual testing scenarios (*)

  1. Put the site into development mode, and disable cache.
  2. Add a breaking change to a layout XML file. e.g add: <bar>foo</bar>
  3. Load the frontend of the site,

You should get an error message that you can use to find the offending configuration.

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

Resolved issues:

  1. resolves [Issue] feat: more informative error message on xml validation errors #37788: feat: more informative error message on xml validation errors

@m2-assistant
Copy link

m2-assistant bot commented Feb 9, 2023

Hi @adamzero1. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.

Add the comment under your pull request to deploy test or vanilla Magento instance:
  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@hostep
Copy link
Contributor

hostep commented Feb 9, 2023

Nice!

However, there was already another improvement made in this area recently I believe: #36239 (it looks like this one is not going to be included in Magento 2.4.6, because it's not in 2.4.6-beta5, and that would really suck, so we'll have to wait until the year 2024 for this one to be included in Magento 2.4.7 ...)

Anyway, not sure if we need both improvements?

@ihor-sviziev ihor-sviziev added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Feb 10, 2023
Copy link
Contributor

@ihor-sviziev ihor-sviziev left a comment

Choose a reason for hiding this comment

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

Could you also please cover your change with any type of automated tests?

@ihor-sviziev
Copy link
Contributor

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@adamzero1
Copy link
Contributor Author

Nice!

However, there was already another improvement made in this area recently I believe: #36239 (it looks like this one is not going to be included in Magento 2.4.6, because it's not in 2.4.6-beta5, and that would really suck, so we'll have to wait until the year 2024 for this one to be included in Magento 2.4.7 ...)

Anyway, not sure if we need both improvements?

I'm not sure of the performance implications of merging on everyfile, considering the number of files that are processed.
Though this would help the file be identified.
I will have a look to see if there is a way to get best of both

@hostep
Copy link
Contributor

hostep commented Mar 15, 2023

Regarding my previous comment, I just ran into a situation where I needed more info to see where an xml error came from exactly and the fix from #36239 didn't help in this particular case, but the fix from this PR did!

So I think both should be processed.
Thanks for the PR!

@ihor-sviziev
Copy link
Contributor

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

Copy link
Contributor

@ihor-sviziev ihor-sviziev left a comment

Choose a reason for hiding this comment

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

Could you also please cover your change with any type of automated tests and fix failing tests?

@ihor-sviziev
Copy link
Contributor

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Echo engcom-Echo self-assigned this Jun 7, 2023
@engcom-Lima
Copy link
Contributor

@magento create issue

@engcom-Lima
Copy link
Contributor

@magento run Functional Tests EE , Functional Tests CE

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.

@engcom-Lima engcom-Lima added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Jul 24, 2023
@engcom-Lima
Copy link
Contributor

@magento run Functional Tests B2B

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.

@engcom-Lima
Copy link
Contributor

engcom-Lima commented Jul 24, 2023

✔️ QA Passed

Preconditions:

  • Install fresh Magento 2.4-develop and PHP 8.1

Manual testing scenario:

  1. Put the site into development mode, and disable the cache.
  2. Add a breaking change to a layout XML file. e.g add: <bar>foo</bar>
  3. Load the front end of the site.

Before: ✖️ Complete information was not available of error message on XML validation errors.
Screenshot 2023-07-24 at 12 19 48 PM
Screenshot 2023-07-24 at 12 24 52 PM

After: ✔️ Now complete information is getting displayed on XML validation errors.
Screenshot 2023-07-24 at 12 26 59 PM
Screenshot 2023-07-24 at 12 27 24 PM
Screenshot 2023-07-24 at 12 27 32 PM

Builds are failed. Hence, moving this PR to Extended Testing.

@engcom-Echo
Copy link
Contributor

@magento run Unit Tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.

@engcom-Echo
Copy link
Contributor

@magento run Unit Tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.

@engcom-Echo
Copy link
Contributor

Functional Failure are not related to the PR changes.
Hence moving to merge in progress.

@engcom-Echo
Copy link
Contributor

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.

@engcom-Echo
Copy link
Contributor

@magento run WebAPI Tests,Unit Tests,Integration Tests,Functional Tests EE

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.

@engcom-Echo
Copy link
Contributor

Functional Tests EE failures are different on last two run on same commit. Other build failures are not related to PR.
Functional Tests EE
Run1
36836-ee

Run2
Screenshot 2023-08-18 at 12 31 27 PM

@magento-devops-reposync-svc magento-devops-reposync-svc merged commit c4c2eac into magento:2.4-develop Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: accept Project: Community Picked PRs upvoted by the community Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Issue] feat: more informative error message on xml validation errors

9 participants