When you have a non-migrated macro definition of a contentbylabel parsed to a MacroDefinition object and then call XhtmlContent.convertMacroDefinitionToStorage the returned XHTML is broken.
In our case we get the page content in the transformer chain "storage to editor" and have to convert the macro body of our own macro back to Xhtml so it can be processed by later parts of the chain.
When the editor content then is saved the broken macro definition is then stored to the page and when you return to viewpage.action, the macro can't be rendered anymore.
You can easily construct the case with some code (have a debugger in the transformation chain to try it out). The MacroDefinition object is what I get from Confluence within a MacroDefinitionReplacer:
The StorageMacroV2Marshaller messes up the representation of the space resource identifier. That's what it looks like: