Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

sphinxcontrib-confluencebuilder not recognising confluence_space_key

Dave Poole August 2, 2022

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
Dave Poole August 3, 2022

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
Product Admin
TAGS
AUG Leaders

Atlassian Community Events