szn / confluence.md

Markdown to Confluence - upload any .md files to your Confluence cloud page
25 stars 10 forks source link

Only providing URL in markdown seems to not be enough for updates #21

Closed mxmo0rhuhn closed 3 months ago

mxmo0rhuhn commented 3 months ago

Hi, thanks a lot for this awesome tool! It helps me a lot to keep Confluence up to date with the actual documentation of the repository.

I recently removed the --page_id and --url for updates as advised by the documentation. Unfortunately, now a crash [1] occurs where it seems like the underlying confluence library does not have the correct host information.

After a quick look at the code, it looks to me like the host information that was correctly parsed from the file is not supplied to the underlying confluence library within atlassian/confluence.py. In Line 104 the host is set for the ConfluenceMD object but not for the atlassian.Confluence class it inherits from.

Providing the --url solves the issue.

[1] Full crash dump:

07:07:35 >  Updates page content based on given page_id or metadata in Markdown file        
07:07:35 > Updating page `None` based on `md_file` file
07:07:35 > Converting MD to HTML
07:07:35 > Getting list of images from MD file
07:07:36 > Looking for host and page_id in https://cyberfy.atlassian.net/wiki/spaces/OI/pages/3735623/How+to+set+up+your+dev+environment url
07:07:36 >   found page_id `12345678` and host `https://xyz.atlassian.net`/
07:07:36 > Using `page_id` from `README.md` file
07:07:36 > Getting page title from page id `12345678`
07:07:36 > Invalid URL 'wiki/rest/api/content/12345678': No schema supplied. Perhaps you meant http://wiki/rest/api/content/12345678?
Traceback (most recent call last):
  File "/home/runner/.local/bin/confluence.md", line 8, in <module>
    sys.exit(main())
  File "/home/runner/.local/lib/python3.10/site-packages/md2cf/main.py", line 183, in main
    raise error
  File "/home/runner/.local/lib/python3.10/site-packages/md2cf/main.py", line 178, in main
    globals()[args.action](args)
  File "/home/runner/.local/lib/python3.10/site-packages/md2cf/main.py", line 21, in wrapper
    function(args)
  File "/home/runner/.local/lib/python3.10/site-packages/md2cf/main.py", line 42, in update
    confluence.update_existing(args.page_id)
  File "/home/runner/.local/lib/python3.10/site-packages/md2cf/utils/confluencemd.py", line 110, in update_existing
    title = self.__get_page_title_by_id(page_id)
  File "/home/runner/.local/lib/python3.10/site-packages/md2cf/utils/confluencemd.py", line 291, in __get_page_title_by_id
    page = self.get_page_by_id(page_id)
  File "/home/runner/.local/lib/python3.10/site-packages/atlassian/confluence.py", line 346, in get_page_by_id
    response = self.get(url, params=params)
  File "/home/runner/.local/lib/python3.10/site-packages/atlassian/rest_client.py", line 341, in get
    response = self.request(
  File "/home/runner/.local/lib/python3.10/site-packages/atlassian/rest_client.py", line 294, in request
    response = self._session.request(
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 530, in request
    prep = self.prepare_request(req)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 458, in prepare_request
    p.prepare(
  File "/usr/lib/python3/dist-packages/requests/models.py", line 316, in prepare
    self.prepare_url(url, params)
  File "/usr/lib/python3/dist-packages/requests/models.py", line 390, in prepare_url
    raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL 'wiki/rest/api/content/12345678': No schema supplied. Perhaps you meant http://wiki/rest/api/content/3735623?
szn commented 3 months ago

Thanks @mxmo0rhuhn for the detailed description and hint. Fixed in 0.4.4:

$ pip install --upgrade confluence.md
szn commented 3 months ago

https://github.com/szn/confluence.md/releases/tag/v0.4.4

mxmo0rhuhn commented 3 months ago

Works like charm! thanks a lot for the swift response!