Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to detect unknown-attachments error in your Confluence instance

Hi!

In this article, we will write a small tool to detect unknown attachments errors in rendered Confluence pages.

These symptoms appeared from irrelevant reference to attachments, lost files on file system level, corrupted data in attachments tables in Confluence DB, or the result of migrated/imported data.

Maybe you can meet with this error many times, like this  

unknown-attachments.PNG

Let's find these easy errors in your confluence. 

1. You need to install python

2. and then

 pip install atlassian-python-api

The Source code of library located is here.

3. An algorithm is easy:

3.1. Get all space keys

3.2.  Get all page ids

3.3. A check has an error or not. The method you can find here

4. Raise the Jira issue for your documentation team :) 

 

Let's see it in python code:

3.1. 

def check_unknown_attachment_in_space(confluence, space_key):
"""
Detect errors in space
:param confluence:
:param space_key:
:return:
"""
page_ids = get_all_pages_ids(confluence, space_key)
print("Start review pages {} in {}".format(len(page_ids), space_key))
for page_id in page_ids:
link = confluence.has_unknown_attachment_error(page_id)
if len(link) > 0:
print(link)

if
__name__ == '__main__':
space_list = confluence.get_all_spaces()
for space in space_list:
print("Start review {} space".format(space['key']))
check_unknown_attachment_in_space(confluence, space['key'])

 

 3.2. Get all page ids

def get_all_pages_ids(conf, space_key):
page_ids = []

limit = 50
flag = True
step = 0
while flag:
values = conf.get_all_pages_from_space(space=space_key, start=step * limit, limit=limit)
step += 1

if len(values) == 0:
flag = False
print("Extracted all pages excluding restricts")
else:
for value in values:
page_ids.append(value.get('id'))

return page_ids

3.3 And last one step is to check the error it is already in the atlassian-python-api library:

link = confluence.has_unknown_attachment_error(page_id)
if len(link) > 0:
print(link)

 

4. If the script will detect some errors then in the output you will find tiny URL links to the page with errors. 

 

Hope it helps detect the problems. 

 

My motivation was a lot of Confluence instances and of course, migrations.

P.S. Full example is here

 

 

Cheers,

Gonchik Tsymzhitov

 

 

0 comments

Comment

Log in or Sign up to comment
TAGS
Community showcase
Published in Confluence Cloud

Confluence Bingo Round 3!

That’s right! Grandma’s back at it again, and this time she’s brought all her friends. In honor of Team '21, this Bingo round is dedicated to all things team-related, and the prizes are no exception....

38 views 0 3
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you