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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,466,080
Community Members
 
Community Events
176
Community Groups

sphinxcontrib-confluencebuilder not recognising confluence_space_key

I am attempting to publish documents to Confluence cloud using sphinxcontrib-confluencebuilder.

I get an error as follows

REQ: POST
RSP: 400
URL: https://crimsonmacaw.atlassian.net/wiki/rest/api
API: content
DATA: {
"statusCode": 400,
"data": {
"authorized": true,
"valid": false,
"errors": [
{
"message": {
"key": "You must specify a space key or space id for new content.",
"args": []
}
}
],
"successful": false
},
"message": "com.atlassian.confluence.api.service.exceptions.BadRequestException: Could not create content with type page"
}

I do have a valid space key.  When I set `confluence_publish_debug=True` I see two HTTP GET statements with an HTTP status of 200, both of which have the space key.

I then get the HTTP400 message above.

Looking at `conf.py` I have the following settings

 

confluence_purge = False
confluence_ask_password = False
confluence_global_labels = python_labels
confluence_parent_page = "Python Repositories"
confluence_parent_page_id_check = 3016196097
confluence_append_labels = True
confluence_remove_title = False
confluence_use_index = False
confluence_page_hierarchy = True
confluence_publish_dryrun = False
confluence_prev_next_buttons_location = 'both'
confluence_header_file = "/opt/docs/sphinx/assets/page_header.tpl"
confluence_publish_debug = False
confluence_publish = True
confluence_space_key = 'TECH' # space_key

The extensions I am using are as follow

extensions = [
"sphinx.ext.napoleon",
"sphinx.ext.duration",
"sphinx.ext.doctest",
"sphinx.ext.autodoc",
"sphinx.ext.viewcode",
"sphinx.ext.autosummary",
"sphinxcontrib.confluencebuilder",
"myst_parser",
"sphinx_markdown_tables",
]

source_parsers = {
'.md': 'recommonmark.parser.CommonMarkParser',
}

source_suffix = [".rst", ".md", ".py"]

The Python library versions I am using are

sphinx==5.0.2
sphinx-markdown-tables==0.0.17
recommonmark==0.7.1
sphinxcontrib-confluencebuilder==1.8.0

I have not included confluence server, user and password for obvious reasons though they are in my conf.py

I can clearly see that

confluence_space_key = 'TECH' # space_key

So how can the Confluence API think I'm sending an empty key?

1 answer

1 accepted

0 votes
Answer accepted

It turns out that the following message is a complete red herring.

You must specify a space key or space id for new content

 The problem was in the confluence_global_labels array.

The values for the labels are picked up from an environment variable.

python_labels =list(os.environ.get("PYTHON_CONFLUENCE_LABELS","").split(" "))

The problem is that this brings back a list with the members we want plus an empty member.  This is the cause of the error.

To fix this we changed the code to get rid of the empty member

python_labels =list(os.environ.get("PYTHON_CONFLUENCE_LABELS","").split(" "))
python_labels=list(filter(None,python_labels))

# ....etc
confluence_global_labels = python_labels

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS

Atlassian Community Events