Fix NullPointerException in CmsADEConfigData.hasFormatters() for resource types without a schema - #846
Open
gallardo wants to merge 1 commit into
Open
Conversation
…source types without a schema. CmsXmlContentDefinition.getContentDefinitionForType() returns null when a resource type has no "schema" configuration parameter. hasFormatters() dereferenced the result unconditionally, causing a NullPointerException (logged by CmsAddDialogTypeHelper on every container page editor load) whenever such a type is referenced by a sitemap configuration. Treat a missing content definition as "no formatters" and log a warning naming the offending type, so the misconfiguration is visible instead of surfacing as an NPE. Co-Authored-By: Claude Code, Fable 5 <noreply@anthropic.com>
Contributor
Author
|
Don't merge yet. I'm still trying to reproduce it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a resource type referenced by a sitemap configuration is defined without a
schemaconfiguration parameter, opening the container page editor logs this error on every add-dialog build:CmsXmlContentDefinition.getContentDefinitionForType()intentionally returnsnullin that case, buthasFormatters()dereferences the result unconditionally. The resultingNullPointerExceptionis swallowed per type byCmsAddDialogTypeHelper, which also means the formatter check is silently skipped for the affected type (it shows up in the add menu even without any matching formatter).Fix
Treat a missing content definition as "no formatters" (
return false) and log a warning that names the offending type, so the underlying misconfiguration is diagnosable from the log instead of surfacing as an NPE.The sibling method
getTypesWithModifiableFormatters()in the same class already handles thenullreturn fromgetContentDefinitionForType()this way.Verification
./gradlew compileJavapasses.🤖 Generated with Claude Code