This issue has been created
There is 1 update.
 
 
XWiki Rendering / cid:jira-generated-image-avatar-19b3a43b-0c04-4ca1-b867-4f9ded9c0c83 XRENDERING-748 Open

A macro with a null id completely breaks the macro picker (NPE)

 
View issue   ·   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-f6c1ba58-2f66-42c5-b169-d35085c832a6 Raphaël Jakse created this issue on 14/Jun/24 08:34
 
Summary: A macro with a null id completely breaks the macro picker (NPE)
Issue Type: cid:jira-generated-image-avatar-19b3a43b-0c04-4ca1-b867-4f9ded9c0c83 Bug
Affects Versions: 16.4.0
Assignee: Unassigned
Attachments: image-2024-06-14-08-30-05-815.png
Components: Macro
Created: 14/Jun/24 08:34
Priority: cid:jira-generated-image-static-minor-e83e47ec-1367-4c1f-a647-08d4dbf9953d Minor
Reporter: Raphaël Jakse
Description:

There is a NPE when the id in a macroId has a null id in DefaultMacroCategoryManager.getMacroCategories().

When there is a macro that returns a macroId with a null id, the macro listing completely breaks in the WYSIWYG editor.

_thumb_42635.png

A null macro id should never happen, it would only in case of a programming mistake. However, I think logging an error would be more appropriate.

I believe this should be easily prevented by storing the id in a variable and checking it for null in the following line:
https://github.com/xwiki/xwiki-rendering/blob/8fcf6ac112103b0b1d0f79d4b5624d2cfe05ce39/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/internal/macro/DefaultMacroCategoryManager.java#L116

The getMacroIdsByCategory method should probably be checked as well.

 
 

1 update

 
cid:jira-generated-image-avatar-f6c1ba58-2f66-42c5-b169-d35085c832a6 Changes by Raphaël Jakse on 14/Jun/24 08:42
 
Description: There is a NPE when the id in a macroId has a is null id in DefaultMacroCategoryManager.getMacroCategories().

When there is a macro that returns a
macroId with a null id macroId , the macro listing completely breaks in the WYSIWYG editor.

!image-2024-06-14-08-30-05-815.png|thumbnail!

A null macro id should never happen, it would only in case of a programming mistake. However, I think logging an error would be more appropriate.

I believe this should be easily prevented by storing the id in a variable and checking it for null in the following line The NPE is at :
https://github.com/xwiki/xwiki-rendering/blob/8fcf6ac112103b0b1d0f79d4b5624d2cfe05ce39/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/internal/macro/DefaultMacroCategoryManager.java#L116

The
trace:


{code}
Caused by: java.lang.NullPointerException: Cannot invoke "org.xwiki.rendering.macro.MacroId.getId()" because "macroId" is null
at org.xwiki.rendering.internal.macro.DefaultMacroCategoryManager.getMacroCategories(DefaultMacroCategoryManager.java:116)
at org.xwiki.rendering.script.RenderingScriptService.getMacroCategories(RenderingScriptService.java:301)
at jdk.internal.reflect.GeneratedMethodAccessor1696.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:571)
at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:554)
at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:221)
... 257 more
{code}



The
[getMacroIdsByCategory|https://github.com/xwiki/xwiki-rendering/blob/8fcf6ac112103b0b1d0f79d4b5624d2cfe05ce39/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/internal/macro/DefaultMacroCategoryManager.java#L144] method should probably be checked as well.