Draft Page Unavailable and Issues Error
Asked by Joe:

We've been using Confluence for a month on the Starter Licence, version 6.11 (self-hosted server). I clicked on the link for the Draft page for the first time and got an error instead of the page. The key part of the error states:

The body of this ContentEntityObject ('Redacted Page Name') was 'BodyType:XHTML' but was expected to be 'BodyType:RAW'.

The page referenced does not exist or has been renamed.

Below is the full error, Any assistance in gaining access to our drafts page would be greatly appreciated.

FULL TEXT OF ERROR

org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getBodyAsString' in class com.atlassian.confluence.content.CustomContentEntityObject threw exception java.lang.UnsupportedOperationException: The body of this ContentEntityObject ('Redacted Page Name') was 'BodyType:XHTML' but was expected to be 'BodyType:RAW' at /users/viewmydrafts.vm\[line 47, column 29\]  
at org.apache.velocity.runtime.parser.node.ASTIdentifier.execute(ASTIdentifier.java:223)

caused by: java.lang.UnsupportedOperationException: The body of this ContentEntityObject ('Redacted Page Name') was 'BodyType:XHTML' but was expected to be 'BodyType:RAW'  
at com.atlassian.confluence.core.ContentEntityObject.getBodyContent(ContentEntityObject.java:290)


Answers:
author: Joe
body: The issue with the trial installation of the Questions for Confluence add-in breaking the Drafts functionality was resolved by Atlassian support. This is a back end solution using SQL:

1. Disable the Questions for Confluence add-in
2. Shut down Confluence
3. Backup the database
4. Update the status to 'deleted' in SQL (this doesn't remove them from the DB):

   ```
   update content set content_status = 'deleted' where contentid in (select c.contentid from content c where pluginkey='com.atlassian.confluence.plugins.confluence-questions:answer-draft');update content set content_status = 'deleted' where contentid in (select c.contentid from content c where pluginkey='com.atlassian.confluence.plugins.confluence-questions:question-draft');
   ```

<!-- -->

1. [Clear the plugin cache](https://confluence.atlassian.com/confkb/how-to-clear-confluence-plugins-cache-297664846.html?_ga=2.164656831.1697681893.1541698917-2058331973.1528395235)
2. Restart Confluence

Thanks to all who helped me through this!


author: Hua Soon SIM _Akeles_
body: One method to fix the issue from the UI is to delete all the questions found at

http://\<confluence-base-url\>/questions

When the question is being deleted, all the comments and drafts related to that question will also be deleted.

This may be an easier for those who are evaluating and only has a few questions added and also don't need to stop Confluence for database updates.

Can refer to <https://jira.atlassian.com/browse/CONFSERVER-55067> for more background.


author: Shannon S
body: Hi Joe,

Did you have Confluence Questions installed at one point? It appears that could cause the issue:

* [CONFSERVER-56058](https://jira.atlassian.com/browse/CONFSERVER-56058) *Disabling Questions plugin breaks drafts page*

> ### Workaround options {#toc-hId-1649493311}
>
1.
   > First option: Disabling collaborative editing, user should be able to navigate to drafts page normally.
2.
   > Second option: Re-enabling question plugin then clear drafts.

Let me know if you have any questions!

Regards,

Shannon

comments: author: Joe
body: Hi Shannon,

Thanks so much for your reply. We had Questions for Confluence installed under a trial licence, and subsequently uninstalled the add-on. I disabled the Confluence Collaborative Editor Plugin, but the error remained.

We have a SQL database storing the data for Confluence over here and I can see the record in the dbo.CONTENT table that contains the reference to the entry causing the error message. Can I delete this record -- or is there a SQL command I can run -- to fix this issue via the data layer? Barring that, is there a way to obtain a second trial licence (the original expired) so I can re-install Questions for Confluence, delete the drafts, and then remove the plugin? (That way I'd be able to retain both drafts and Collaborative Editing.)

Any further assistance you could provide would be greatly appreciated.

Cheers,

Joe


author: Shannon S
body: Hi Joe,

There's a 3rd option we're exploring regarding removing relevant entries in the database. We haven't yet confirmed the exact deletion query but the following will get you a list of entries related to Confluence Questions:

```
select *from contentinner join bodycontent on content.contentid = bodycontent.contentidwhere content.contenttype = 'CUSTOM' AND content.pluginkey = 'com.atlassian.confluence.plugins.confluence-questions:answer-draft';
```

In the meantime, you could review [this article](https://confluence.atlassian.com/confkb/how-to-manually-remove-stale-drafts-from-confluence-database-951392345.html) for information on clearing stale drafts, and perhaps can get it to work for your instance?

Keep an eye on the bug ticket as I've asked for an update there about the query that will help clear CQ drafts.

Regards,

Shannon


author: Joe
body: Hi Shannon,

The needed to change the pluginkey for your query to

```
dbo.CONTENT.PLUGINKEY = 'com.atlassian.confluence.plugins.confluence-questions:question-draft'
```

as the offending SQL entry is a question-draft, not an answer-draft.

I tried a few things, but was reluctant to run the entire series of deletes you provided without knowing the Confluence data structure better and understanding what the ramifications of running all those deletes might be.

Does Atlassian have a data schema diagram/notes it can provide? If not, I will have to wait for the bug fix.

Thanks.


author: Shannon S
body: Hi Joe,

Thank you for bringing that up - I was copying the query from one of the comments on the bug that we were working with in regards to a 3rd workaround. I had not modified it from it's original version.

Here is some information on the [Confluence data model](https://confluence.atlassian.com/doc/confluence-data-model-127369837.html) that you may find useful.

If I were you, I would create [a staging instance](https://confluence.atlassian.com/doc/create-a-staging-environment-for-upgrading-confluence-866094180.html), test the fix there, and if that works, then you could apply the fix to your production environment. You'll still want to make sure to have a backup that you can fall back on in case there's an issue.

Otherwise, I've left a comment internally on the bug ticket asking if we have any updates on a verified SQL query that would accomplish the same thing.

Regards,

Shannon


author: Joe
body: Hi Shannon,

Thank you for the data model info. Unfortunately, a staging environment is a cart and horse problem for me. We are running Confluence with an initial group of 10 users. If this group finds value in the product (and I believe the value is immense) we may expand to 50 people in the next iteration. However, no staging environment will be provided by my firm until we decide to go beyond the current use population for Confluence.

If installing a second trial of Questions for Confluence (Atlassian would need to provide this), clearing out the drafts, and uninstalling the trial would work, then I am still willing to try that. Otherwise I will have to wait for the bug fix and hope that my users are not too inconvenienced.

Thanks so much for all your help on this!

Joe


author: Shannon S
body: Hi Joe,

It's possible to get an evaluation license for both Confluence and Confluence Questions if you need to temporarily set up your test instance. That shouldn't be any problem at all.

We always recommend that any database modifications be tested first on a staging instance prior proceeding. Even if a specific query is proven to work on Confluence, you can never truly know how your instance will respond to the change.

Direct database modification is always recommended only as a last resort, per our [Support Offerings](https://confluence.atlassian.com/support/atlassian-support-offerings-193299636.html):
>
> ##### SQL QUERIES {#toc-hId-1256578891}
>
> ###### Modifying data {#toc-hId--1492091575}
>
> Atlassian does not support customers performing direct data manipulation of application databases via queries such as INSERT, UPDATE or DELETE, as they can easily lead to data integrity problems. If Atlassian encounters manipulation or customizations at this level, we may ask customers to restore data from their last known working state, or to engage an Expert to help recover their instance to a supportable state. If you are confident your UPDATE or INSERT is safe and your change management system is reliable, refer to the specific product's database documentation.

I would recommend in this case that you either:

1. Re-enable Questions on your Production instance to clear your drafts.
2. Vote and watch the bug for any updates as to when we have a deletion query that is proven to work in this situation.

I have reached out to the devs on this bug in question to see if they have any updates to offer on the deletion query, but your more immediate resolution would be to re-enable Questions.

Regards,

Shannon


author: Joe
body: Hi Shannon,

I tried the following:

1. I obtained a second trial license for Questions for Confluence.
2. I re-installed Questions for Confluence and activated it.
3. The Drafts page displays. However the draft cannot be deleted. When I click the link to discard the draft, I do get the confirmation box. But when I confirm "Yes" to remove it, the box disappears and nothing happens.
4. When I disabled the Questions for Confluence add-in after this attempt, the issue remained and Drafts are inaccessible.
5. I tried disabling Collaborative editing with the Questions for Confluence add-in enabled and disabled. Neither resolved the issue.

Thanks,

Joe


author: Shannon S
body: Thanks, Joe. The 2nd trial license was for your production instance, correct? You are currently still not able to build a staging instance?

We really would need to see your logs as well to know why the other workarounds aren't working out for you. I'm creating a support ticket now for you so you can send those over to us.

Check your email in a bit and you should have the ticket number.

Regards,

Shannon


author: Joe
body: Hi Shannon,

Thanks so much for creating the ticket. I have uploaded our logs to it and added information on a new issue: Collaborative Editing stops post creation.

From Jira ticket:

In addition to the two existing workarounds having no affect on my inability to use the Confluence Drafts function, I can no longer use Collaborative editing. When I turn Collaborative editing on, we can no longer create new posts in Confluence. Upon trying to create a post, the system hangs indefinitely and creates a draft instead. The draft that is created hangs if trying to click on the "Resume" link.

Much appreciated,

Joe


author: Shannon S
body: Thanks, Joe!

Looks like Manuel will be helping you out now as he's received your logs.

Once the issue is resolved, please feel free to come here and update us in case other users have this problem in the future.

Regards,

Shannon


author: Joe
body: The issue with the trial installation of the Questions for Confluence add-in breaking the Drafts functionality was resolved by Atlassian support. This is a back end solution using SQL:

1. Disable the Questions for Confluence add-in
2. Shut down Confluence
3. Backup the database
4. Update the status to 'deleted' in SQL (this doesn't remove them from the DB):

   ```
   update content set content_status = 'deleted' where contentid in (select c.contentid from content c where pluginkey='com.atlassian.confluence.plugins.confluence-questions:answer-draft');update content set content_status = 'deleted' where contentid in (select c.contentid from content c where pluginkey='com.atlassian.confluence.plugins.confluence-questions:question-draft');
   ```

<!-- -->

1. [Clear the plugin cache](https://confluence.atlassian.com/confkb/how-to-clear-confluence-plugins-cache-297664846.html)
2. Restart Confluence

Thanks to all who helped me through this!


Tags: confluence-server

server