Problem with "Confluence CLI Connector" and Attachments (docx)
Asked by Daniel Vehof:

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 '... &lt;PART OF THE DOCX HERE&gt; ... ' 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!


Answers:
author: Bob Swift (personal)
body: 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"
```

comments: author: Daniel Vehof
body: 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.


author: Daniel Vehof
body: 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:  -&gt;[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: &lt;MYUSERID&gt;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: &lt;MYUSERID&gt;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!


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


author: Bob Swift (personal)
body: 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](/html/@C495B4504065515364EB1894F812B34C/images/emoticons/sad.png "sad")


author: Daniel Vehof
body: Thanks for your response! We will give it a try.


author: Rob Woodgate
body: The CLI developer, @Bob Swift \[Bob Swift Atlassian Add-ons\] will see this mention and be along shortly :smile:

comments: author: Daniel Vehof
body: Thanks for the hint :smile:


Tags: cli