Problem with "Confluence CLI Connector" and Attachments (docx)

Hi,

we are currently evaluating if we can change some URLs in confluence pages with the Confluence CLI Connector. At the moment we have got Problems with attached docx files. The cli connector seems to try to change the URLs even in the docx files. But something goes wrong there.

From the logfile:

caused by: java.lang.IllegalArgumentException: The char '0x13' in 'java.io.IOException: java.lang.IllegalArgumentException: The char '0x13' in '... <PART OF THE DOCX HERE> ... ' is not a valid XML character.' is not a valid XML character.
at org.apache.axis.components.encoding.AbstractXMLEncoder.encode(AbstractXMLEncoder.java:110)

Is there anything we are doing wrong? Can we exclude attachments (or docx)? We use the atlassian-cli 6.1.0 (on linux) and the latest plugin version.

this is how we try to do it:

./confluence.sh --server https://url.to/confluence --user USERNAME --password "PASSWORD" --action runFromContentList --search "\"https://OLD.URL/confluence\"" --space @all --common "--action modifyPage --id @pageId@ --findReplace \"https://OLD.URL/confluence###https://NEW.URL/confluence\" --special \" ###\" "

Thanks for any help!

2 answers

The CLI developer, @Bob Swift [Bob Swift Atlassian Add-ons] will see this mention and be along shortly smile

Thanks for the hint smile

It would be more helpful if you provide the results from a CLI action that shows an error. 

In any case, modifyPage only changes pages. A suggestion also would be to use the cql parameter instead of search, something like:

--cql "text ~ 'https://OLD.URL/confluence' and type = page"

Thanks for your answer!

It works with --cql instead of --search. So the problem seems to be, that --search also searches in attachments (in my case docx) and this fails somehow.

CLI only says:

Remote error: (500)Internal Server Error

The entries in the confluence logfile are as mentioned above in my first post.

But as --cql works, and if you say it is equal to --search in this case, this will be enough for me.

Sorry, it's me again. 

Now tried the same command (with --cql) that worked for the confluence URL to replace an old JIRA URL in the same confluence instance.

Replacing the JIRA URL fails:

cli output says:

Remote error: java.lang.NullPointerException: null

confluence log says:

2017-02-27 13:18:21,652 WARN [ajp-nio-8010-exec-10] [confluence.impl.hibernate.ConfluenceHibernateTransactionManager] doRollback Performing rollback. Transactions:
  ->[com.atlassian.confluence.api.impl.service.content.finder.ContentFinderFactory$ContentFinderImpl.fetchMappedByContentType]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly (Session #1429300833)
 -- url: /confluence/rest/api/latest/content/search | traceId: 32196a5a9e309e11 | userName: <MYUSERID>
2017-02-27 13:18:21,653 ERROR [ajp-nio-8010-exec-10] [rest.api.model.ExceptionConverter] convertServiceException No status code found for exception, converting to internal server error : 
 -- url: /confluence/rest/api/latest/content/search | traceId: 32196a5a9e309e11 | userName: <MYUSERID>
java.lang.NullPointerException
	at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:210)
	at com.atlassian.confluence.api.model.content.History$HistoryBuilder.createdDate(History.java:231)
	at com.atlassian.confluence.api.impl.service.content.factory.HistoryFactory.buildRef(HistoryFactory.java:102)
	at com.atlassian.confluence.api.impl.service.content.factory.HistoryFactory.buildReferences(HistoryFactory.java:56)
	at com.atlassian.confluence.api.impl.service.content.factory.ContentFactory.addCommonFieldsToBuilders(ContentFactory.java:161)
	at com.atlassian.confluence.api.impl.service.content.factory.ContentFactory.buildersFrom(ContentFactory.java:154)
	at com.atlassian.confluence.api.impl.service.content.factory.ContentFactory.buildFrom(ContentFactory.java:103)
	at com.atlassian.confluence.api.impl.service.content.finder.ContentFinderFactory$ContentFinderImpl.lambda$fetchMany$1(ContentFinderFactory.java:123)
	at com.atlassian.confluence.api.impl.pagination.PaginationServiceImpl.executeBatch(PaginationServiceImpl.java:167)
	at com.atlassian.confluence.api.impl.pagination.PaginationServiceImpl.lambda$doRequestInTransaction$1(PaginationServiceImpl.java:143)
	at com.atlassian.confluence.api.impl.ReadOnlyAndReadWriteTransactionConversionTemplate.executeInReadOnly(ReadOnlyAndReadWriteTransactionConversionTemplate.java:40)
	at com.atlassian.confluence.api.impl.pagination.PaginationServiceImpl.doRequestInTransaction(PaginationServiceImpl.java:138)
	at com.atlassian.confluence.api.impl.pagination.PaginationServiceImpl.doPaginationListRequest(PaginationServiceImpl.java:70)
	at com.atlassian.confluence.api.impl.service.content.finder.ContentFinderFactory$ContentFinderImpl.fetchMany(ContentFinderFactory.java:117)
	at com.atlassian.confluence.api.impl.service.content.finder.ContentFinderFactory$ContentFinderImpl.fetchMappedByContentType(ContentFinderFactory.java:153)
...

Maybe you have another hint for me.
Thanks! 

@Bob Swift [Bob Swift Atlassian Add-ons]: The problem still exists, you got any other hint for us?

The log shows it is a Confluence server error running the CQL. Your CQL looks ok. Generally, REST APIs are not suppose to result in server errors - that implies a problem on the Confluence side. That means you will need to open a Atlassian support issue and give them the Confluence version, the CQL used and the stack trace. sad

Thanks for your response! We will give it a try.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Confluence

Three common content challenges + how to manage them

An efficient enterprise content management system, or ECM, is a must-have for companies that create work online (cough   cough, all companies). If content calendars, marketing plans, and bu...

89 views 0 6
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you