Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConvertTo-StorageFormat UnknownMacroMigrationException #177

Open
ghost opened this issue Nov 18, 2019 · 5 comments
Open

ConvertTo-StorageFormat UnknownMacroMigrationException #177

ghost opened this issue Nov 18, 2019 · 5 comments

Comments

@ghost
Copy link

ghost commented Nov 18, 2019

Description

Converting a string to confluence storage format with ConvertTo-ConfluenceStorageFormat returns the error com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException.

Steps To Reproduce

[System.String]$JobDescription = @'
<#
	.NOTES
	===========================================================================
	 Created on:
	 Created by:
	 Created for:
	===========================================================================
	.DESCRIPTION
		

        [PSCustomObject[]]$FileToExtend = @(
            [PSCustomObject]@{
                Path = 'C:\Temp\Test.txt' #[System.String]
                LastAccessTime = '12.11.2035' #[System.DateTime]
            },
            [PSCustomObject]@{
                Path = 'C:\Temp\Test.txt' #[System.String]
                LastAccessTime = '12.11.2035' #[System.DateTime]
            }
        )
#>
'@

ConvertTo-ConfluenceStorageFormat -Content $JobDescription
WARNUNG: Confluence returned HTTP error 500 - InternalServerError
Invoke-Method : com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro '
                path = 'c' is unknown.
In .\Modules\ConfluencePS\Public\ConvertTo-StorageFormat.ps1:43 Zeichen:14
+             (Invoke-Method @iwParameters).value
+              ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidResult: ({"statusCode":5... Server Error"}:String) [Invoke-Method], ArgumentException
    + FullyQualifiedErrorId : InvalidResponse.Status500,Invoke-Method

Expected Output

<p>&lt;#<br/>
	.NOTES<br/>
	===========================================================================<br/>
	 Created on:<br/>
	 Created by:<br/>
	 Created for:<br/>
	===========================================================================<br/>
	.DESCRIPTION</p>


<p>        [PSCustomObject[]]$FileToExtend = @(<br/>
			[PSCustomObject]@{<br/>
				Path = 'C:\Temp\Test.txt' #[System.String]<br/>
				LastAccessTime = '12.11.2035' #[System.DateTime]<br/>
			},<br/>
			[PSCustomObject]@{<br/>
				Path = 'C:\Temp\Test.txt' #[System.String]<br/>
				LastAccessTime = '12.11.2035' #[System.DateTime]<br/>
			}<br/>
		)<br/>

<p>
#&gt;</p>

Your Environment

Confluence 7.0.1

Get-Host
Name             : Windows PowerShell ISE Host
Version          : 5.1.18362.145

Get-Module -Name ConfluencePS
Name              : ConfluencePS
Description       : PowerShell module to interact with the Atlassian Confluence REST API
Version           : 2.5

@lipkau
Copy link
Member

lipkau commented Nov 18, 2019

converting an array of c# objects is probably unknown to confluence.
what is the output that you are expecting?

@lipkau
Copy link
Member

lipkau commented Nov 18, 2019

if you are looking for a able format, try this:

[PSCustomObject]@{
    Path = 'C:\Temp\Test.txt' #[System.String]
    LastAccessTime = '12.11.2035' #[System.DateTime]
},
[PSCustomObject]@{
    Path = 'C:\Temp\Test.txt' #[System.String]
    LastAccessTime = '12.11.2035' #[System.DateTime]
} | ConvertTo-ConfluenceTable | ConvertTo-ConfluenceStorageFormat

@ghost
Copy link
Author

ghost commented Nov 18, 2019

I would expect the following Output:

<p>&lt;#<br/>
	.NOTES<br/>
	===========================================================================<br/>
	 Created on:<br/>
	 Created by:<br/>
	 Created for:<br/>
	===========================================================================<br/>
	.DESCRIPTION</p>


<p>        [PSCustomObject[]]$FileToExtend = @(<br/>
			[PSCustomObject]@{<br/>
				Path = 'C:\Temp\Test.txt' #[System.String]<br/>
				LastAccessTime = '12.11.2035' #[System.DateTime]<br/>
			},<br/>
			[PSCustomObject]@{<br/>
				Path = 'C:\Temp\Test.txt' #[System.String]<br/>
				LastAccessTime = '12.11.2035' #[System.DateTime]<br/>
			}<br/>
		)<br/>

<p>
#&gt;</p>

@lipkau
Copy link
Member

lipkau commented Nov 18, 2019

The problem with your case is the chars that confluence tries to convert into macros.
This works for me using your $JobDescription:

ConvertTo-ConfluenceStorageFormat ($JobDescription -replace "#", "&#35;" -replace "@", "&#64;" -replace "\[", "&#
91;" -replace "\{", "&#123;")

@ghost
Copy link
Author

ghost commented Nov 18, 2019

Thank you Oliver, that works for me. I created a pull request (#178). Would be nice to add the ability to handle this cases directly with the function ConvertTo-ConfluenceStorageFormat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant