Details
-
Bug
-
Resolution: Unresolved
-
Medium
-
Severity 3 - Minor
-
Description
See Connect doc:
- https://developer.atlassian.com/cloud/confluence/jsapi/confluence/
- https://developer.atlassian.com/cloud/confluence/modules/macro-editor/
The doc says about macroBody of saveMacro:
"the macro body to be saved with the macro. If omitted, the existing body will remain untouched."
My macro has a custom editor dialog. When I insert my macro, the dialog is displayed.
In the dialog close handler, I set macro params without body like this:
confluence.saveMacro(macroParams);
There will be NPE:
user-activity-xhr-header.js:54
POST http://localhost:8080/wiki/rest/tinymce/1/macro/placeholder 500 (Internal Server Error)
Stacktrace:
java.lang.NullPointerException: Missing storage body at java.util.Objects.requireNonNull(Objects.java:228) at com.atlassian.confluence.content.render.xhtml.definition.RichTextMacroBody.withStorage(RichTextMacroBody.java:18) at com.atlassian.confluence.tinymceplugin.rest.MacroResource.getMacroBody(MacroResource.java:157) at com.atlassian.confluence.tinymceplugin.rest.MacroResource.generatePlaceHolder(MacroResource.java:134) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498)
Workaround
You need to call saveMacro({}, body) with a body value. If the macro has a body, you will need to pre-fetch it with getMacroBody().