sphinx-contrib / confluencebuilder

Confluence Markup Builder Plugin for Sphinx
BSD 2-Clause "Simplified" License
317 stars 99 forks source link

Updating confluence pages fails on v2 #953

Closed cdcadman closed 7 months ago

cdcadman commented 7 months ago

After upgrading to version 2.5.0, I'm not able to update existing Confluence pages using python -m sphinx -M confluence . _build. If I downgrade to version 2.4.0, run the command, and then upgrade to version 2.5.0, it works. Is there a way to make the latest version work directly without the extra step?

This is the log from the initial failing run on version 2.5.0:

# Platform:         win32; (Windows-11-10.0.22631-SP0)
# Sphinx version:   7.2.6
# Python version:   3.12.0 (CPython)
# Docutils version: 0.20.1
# Jinja2 version:   3.1.3
# Pygments version: 2.17.2

# Last messages:
#   
#   
#   
#   publishing documents... [ 10%]
#   index
#   
#   
#   publishing documents... [ 20%]
#   readme_link
#   

# Loaded extensions:
#   sphinx.ext.mathjax (7.2.6)
#   alabaster (0.7.16)
#   sphinxcontrib.applehelp (1.0.8)
#   sphinxcontrib.devhelp (1.0.6)
#   sphinxcontrib.htmlhelp (2.0.5)
#   sphinxcontrib.serializinghtml (1.1.10)
#   sphinxcontrib.qthelp (1.0.7)
#   sphinx.ext.autodoc.preserve_defaults (7.2.6)
#   sphinx.ext.autodoc.type_comment (7.2.6)
#   sphinx.ext.autodoc.typehints (7.2.6)
#   sphinx.ext.autodoc (7.2.6)
#   sphinx.ext.viewcode (7.2.6)
#   sphinx.ext.napoleon (7.2.6)
#   sphinxcontrib.jquery (4.1)
#   sphinx_rtd_theme (unknown version)
#   sphinx.ext.intersphinx (7.2.6)
#   sphinxcontrib.mermaid (7.2.6)
#   myst_parser (2.0.0)
#   sphinxcontrib.confluencebuilder (2.5.0)

# Traceback:
Traceback (most recent call last):
  File "C:\Program Files\Python312\Lib\site-packages\sphinx\cmd\build.py", line 298, in build_main
    app.build(args.force_all, args.filenames)
  File "C:\Program Files\Python312\Lib\site-packages\sphinx\application.py", line 355, in build
    self.builder.build_update()
  File "C:\Program Files\Python312\Lib\site-packages\sphinx\builders\__init__.py", line 293, in build_update
    self.build(to_build,
  File "C:\Program Files\Python312\Lib\site-packages\sphinx\builders\__init__.py", line 366, in build
    self.finish()
  File "C:\Program Files\Python312\Lib\site-packages\sphinxcontrib\confluencebuilder\builder.py", line 760, in finish
    self.publish_doc(docname, output)
  File "C:\Program Files\Python312\Lib\site-packages\sphinxcontrib\confluencebuilder\builder.py", line 509, in publish_doc
    uploaded_id = self.publisher.store_page(title, data, parent_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python312\Lib\site-packages\sphinxcontrib\confluencebuilder\publisher.py", line 1093, in store_page
    self._update_page(page, page_name, data, parent_id=parent_id)
  File "C:\Program Files\Python312\Lib\site-packages\sphinxcontrib\confluencebuilder\publisher.py", line 1556, in _update_page
    updated_prop['id'] = orig_entry['id']
                         ~~~~~~~~~~^^^^^^
KeyError: 'id'

Here is my configuration:

(system)
 platform: Windows-11-10.0.22631-SP0
   python: 3.12.0 (tags/v3.12.0:0fb18b0, Oct 2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)]
   sphinx: 7.2.6
 docutils: 0.20.1
 requests: 2.31.0
  urllib3: 2.1.0
  builder: 2.5.0

(configuration)
confluence_disable_autogen_title: True
confluence_page_hierarchy: True
confluence_parent_page: (set)
confluence_publish: True
confluence_server_pass: (set)
confluence_server_url: https://(removed) (cloud)
confluence_server_user: (set)
confluence_space_key: (set; mixed)

(confluence instance)
 connected: yes
   fetched: yes
   decoded: yes
    parsed: yes
      type: confluence
   version: 1000.0.0-5dc985662b86
jdknight commented 7 months ago

@cdcadman, thanks for reporting this. For sure a bug has been introduced to support the new Cloud APIs. I will try to push out a fix/release this weekend to address this.

As for now, a workaround would be to force using the older/original API mode when using a Cloud target:

confluence_api_mode = 'v1'
jdknight commented 7 months ago

An update has been made to the implementation which should address this issue, and a v2.5.1 release has been made and published to PyPI. Will go ahead and close this issue, assuming it has resolved this use case. Feel free to comment here if there are still issues (which we can re-open and try to address).