Confluence Template creation fails with "The space key could not be found" when using Office Excel/Word macros

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Low
    • None
    • Affects Version/s: 8.5.30, 10.2.7, 9.2.18
    • Component/s: Macros - Other Macros
    • None
    • Severity 3 - Minor

      Issue Summary

      When attempting to create or save a Confluence page template that includes an Office Macro (Excel or Word) referencing an attachment, the operation fails. The macro fails to render in the preview/editor, and the application logs throw a com.atlassian.confluence.macro.MacroExecutionException: The space key could not be found.

      Additionally, when attempting to save the template, the user is presented with the following UI error:
      "Failure when converting editor format to storage format."

      Steps to Reproduce

      1. Create a new Page
      2. Add excel sheet to the page as an attachment. Example: TestExcelAttachment.xls
      3. Go to ⚙️ → Space tools → Content tools → Create New template → Click "+" Office Excel.
      4. Search page name and attachment name will be auto populated > Click perview button and "com.atlassian.confluence.macro.MacroExecutionException: The space key could not be found" error is displayed.
      5. Click Insert > Click Save > "Failure when converting editor format to storage format." error is displayed.

      Expected Results

      The Office Macro should correctly resolve the space context within the template editor, allowing the file to be previewed and the template to be saved successfully.

      Actual Results

      • The macro placeholder displays: "The space key could not be found."
      • Saving the template fails with: "Failure when converting editor format to storage format."
      • In the logs, could see below error:
      2026-04-08 13:31:01,195 WARN [http-nio-8090-exec-133 url: /confluence/rest/tinymce/1/macro/preview; user: admin] [xhtml.view.macro.ViewMacroMarshaller] handleMacroExecutionException Exception executing macro: viewxls, with message: com.atlassian.confluence.macro.MacroExecutionException: com.atlassian.confluence.macro.MacroExecutionException: The space key could not be found. 
      2026-04-08 13:31:21,978 WARN [http-nio-8090-exec-160 url: /confluence/pages/templates2/doeditpagetemplate.action; user: admin] [content.render.xhtml.DefaultFormatConverter] validateAndConvertToStorageFormat XhtmlException converting editor format to storage format. Turn on debug level logging to see editor format data.
       -- url: /confluence/pages/templates2/doeditpagetemplate.action | userName: admin | action: doeditpagetemplate | referer: https://linux-123362.prod.atl-cd.net/confluence/pages/templates2/editpagetemplate.action?entityId=1474561&key=TES | traceId: 8dbdc9301689977b
      com.atlassian.confluence.content.render.xhtml.XhtmlException: RuntimeException occurred while transforming editor format to storage format (Error creating resource identifier for resource page: Template Preview v.1 (0): Resource not supported.)
      	at com.atlassian.confluence.content.render.xhtml.editor.EditorXhtmlTransformer.lambda$transform$0(EditorXhtmlTransformer.java:59)
      	at com.atlassian.confluence.content.render.xhtml.StaxUtils.processWrappedWstxExceptionOrTrowMapped(StaxUtils.java:465)
      	at com.atlassian.confluence.content.render.xhtml.editor.EditorXhtmlTransformer.transform(EditorXhtmlTransformer.java:59)
      	at com.atlassian.confluence.content.render.xhtml.TransformerChain.transform(TransformerChain.java:41)
      	at com.atlassian.confluence.content.render.xhtml.TransformerChain.transform(TransformerChain.java:41)
      	at com.atlassian.confluence.content.render.xhtml.PluggableTransformerChain.transform(PluggableTransformerChain.java:42)
      	at com.atlassian.confluence.content.render.xhtml.editor.DefaultEditorConverter.convert(DefaultEditorConverter.java:37)
      	at com.atlassian.confluence.content.render.xhtml.DefaultFormatConverter.convertToStorageFormat(DefaultFormatConverter.java:122)
      	at com.atlassian.confluence.content.render.xhtml.DefaultFormatConverter.validateAndConvertToStorageFormat(DefaultFormatConverter.java:72)
      	at com.atlassian.confluence.content.render.xhtml.DefaultFormatConverter.validateAndConvertToStorageFormat(DefaultFormatConverter.java:55)
          Caused by: com.atlassian.confluence.content.render.xhtml.model.resource.identifiers.ResourceIdentifierCreationException: Error creating resource identifier for resource page: Template Preview v.1 (0): Resource not supported.
      	at com.atlassian.confluence.content.render.xhtml.editor.macro.MacroParameterTypeParserImpl.createAttachmentContainerResourceIdentifier(MacroParameterTypeParserImpl.java:223)
      	at com.atlassian.confluence.content.render.xhtml.editor.macro.MacroParameterTypeParserImpl.parseSingleMacroParameter(MacroParameterTypeParserImpl.java:180) 

      Workaround

      If the requirement is to add Excel to the template, you can try the workaround below. I have tested it on my local machine.

      1. Create a page and attach the required Excel document
      2. When you create a template, click the "insert files and images" option
      3. Select Search on the other pages tab
      4. Search for the name of the Excel file and insert
      5. This way, you will be able to save the template and use it to create new pages

        1. SpaceKeyError.png
          348 kB
          Naveen Ravi
        2. Templateattachment.png
          296 kB
          Naveen Ravi
        3. FileAttachment.png
          320 kB
          Naveen Ravi
        4. StorageFormatError.png
          217 kB
          Naveen Ravi
        5. TestExcelAttachment.xls
          14 kB
          Naveen Ravi

              Assignee:
              Unassigned
              Reporter:
              Naveen Ravi
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: