Skip to content

Conversation

@CybotTM
Copy link
Contributor

@CybotTM CybotTM commented Dec 8, 2025

Summary

Instead of crashing with a PHP Fatal error when guides.xml contains invalid configuration, the guides entrypoint now catches InvalidTypeException and InvalidConfigurationException and displays a helpful error message.

Before:

PHP Fatal error:  Uncaught Symfony\Component\Config\Definition\Exception\InvalidTypeException: 
Invalid type for path "guides.theme". Expected "scalar", but got "array". in ...
Stack trace:
#0 ...
(20+ lines of stack trace)

After:

 Invalid guides.xml configuration 

Your guides.xml file contains a configuration error:
  Invalid type for path "guides.theme". Expected "scalar", but got "array".

Common causes:
  - Invalid or unknown XML element
  - Missing required attributes
  - Invalid attribute values or types

Run vendor/bin/typo3-guides lint-guides-xml for detailed validation.
See: https://docs.typo3.org/m/typo3/docs-how-to-document/main/en-us/GeneralConventions/GuideXml.html

Approach

This is a minimal fix that catches exceptions and provides a user-friendly error message. It's simple (~25 lines) but doesn't provide line numbers or specific validation details.

Alternative

See also the companion PR with a comprehensive fix that validates against XSD schema before loading, providing exact line/column numbers: #1118

Test plan

  • Create a malformed guides.xml with <theme name="typo3docs" /> as child element
  • Run bin/guides run --config=Documentation Documentation
  • Verify helpful error message is shown instead of PHP Fatal error
  • Verify valid guides.xml files still render correctly

@linawolf
Copy link
Member

linawolf commented Dec 8, 2025

failing tests are unrelated, I need to fix them first

@CybotTM CybotTM force-pushed the fix/improve-guidesxml-error-handling branch from 62d5193 to add60cc Compare December 8, 2025 14:21
Instead of crashing with a PHP Fatal error when guides.xml contains
invalid configuration (e.g., using <theme name="..."/> element
instead of theme="..." attribute), the guides entrypoint now catches
InvalidTypeException and InvalidConfigurationException and displays
a helpful error message.

The message includes:
- The actual configuration error
- Common causes of the error
- A correct format example
- Suggestion to run lint-guides-xml for detailed validation

Resolves the confusing "Expected scalar, but got array" fatal error
that users encounter with malformed guides.xml files.
@CybotTM CybotTM force-pushed the fix/improve-guidesxml-error-handling branch from 7fbd49a to 70862af Compare December 9, 2025 10:05
Copy link
Contributor

@garvinhicking garvinhicking left a comment

Choose a reason for hiding this comment

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

I think this looks helpful... not too sure about possible impacts when catching these very specific exceptions, so I'd like some more vote/feedback on this patch, especially due to the AI usage.

@linawolf linawolf merged commit d2e1a2a into TYPO3-Documentation:main Dec 11, 2025
8 checks passed
@CybotTM
Copy link
Contributor Author

CybotTM commented Dec 12, 2025

@garvinhicking,

not too sure about possible impacts when catching these very specific exceptions, so I'd like some more vote/feedback on this patch

That's why I also provided a more comprehensive patch with #1118

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.

3 participants