-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Description
Hello! I'm experiencing an issue adding tags (and only tags) to an existing Confluence page on Confluence v8.5.3 with md2cf v2.3.0. Here is my simple repro case:
Tagless:
$ cat simple.md
# Lorem Ipsum
Lorem ipsum dolor sit amet
$ md2cf -o "https://${CONFLUENCE_URL}/rest/api" -u nate.woythaler -s "~nate.woythaler" ./simple.md --debug
📄️ Lorem Ipsum ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ✔️ Created
Total progress ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
$ diff -y --suppress-common-lines simple_labels.md simple.md
--- <
labels: <
- Lorem <
- Ipsum <
--- <
$ md2cf -o "https://${CONFLUENCE_URL}/rest/api" -u nate.woythaler -s "~nate.woythaler" ./simple_labels.md --debug 2>&1 > debug.log... and the redacted debug log:
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/natewo/Repositories/hack-kf-as-code/.venv/lib/python3.11/site-packages/md2cf/__main__.py:4 │
│ 06 in main │
│ │
│ 403 │ │ │ │ tui.set_item_progress_label(page.original_title, "Upserting") │
│ 404 │ │ │ │ final_page = None │
│ 405 │ │ │ │ if not args.dry_run: │
│ ❱ 406 │ │ │ │ │ upsert_page_result = upsert_page( │
│ 407 │ │ │ │ │ │ confluence=confluence, │
│ 408 │ │ │ │ │ │ message=args.message, │
│ 409 │ │ │ │ │ │ page=page, │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ args = Namespace(host='https://${___CF_URL___}/rest/api', │ │
│ │ username='nate.woythaler', password=None, │ │
│ │ token='tokentokentokentokentokentokentokentokentoke', │ │
│ │ insecure=False, space='~nate.woythaler', │ │
│ │ output='default', parent_title=None, parent_id=None, │ │
│ │ top_level=False, title=None, content_type='page', │ │
│ │ message=None, minor_edit=False, page_id=None, │ │
│ │ prefix=None, strip_top_header=False, │ │
│ │ remove_text_newlines=False, replace_all_labels=False, │ │
│ │ preface_markdown=None, preface_file=None, │ │
│ │ postface_markdown=None, postface_file=None, │ │
│ │ collapse_single_pages=False, use_gitignore=True, │ │
│ │ beautify_folders=False, use_pages_file=False, │ │
│ │ collapse_empty=False, skip_empty=False, │ │
│ │ enable_relative_links=False, │ │
│ │ ignore_relative_link_errors=False, dry_run=False, │ │
│ │ debug=True, only_changed=False, │ │
│ │ file_list=[PosixPath('simple_labels.md')], │ │
│ │ max_retries=4) │ │
│ │ colliding_titles = [] │ │
│ │ confluence = <md2cf.api.MinimalConfluence object at │ │
│ │ 0x7f75420936d0> │ │
│ │ e = AttributeError("'Bunch' object has no attribute │ │
│ │ 'metadata'") │ │
│ │ error = None │ │
│ │ final_page = None │ │
│ │ map_document_path_to_confluence_page = {} │ │
│ │ page = Page(title='Lorem Ipsum', │ │
│ │ file_path=PosixPath('simple_labels.md'), │ │
│ │ page_id=None, parent_id=None, parent_title=None, │ │
│ │ space='~nate.woythaler', body='<h1>Lorem │ │
│ │ Ipsum</h1>\n<p>Lorem ipsum dolo [...]') │ │
│ │ page_title_counts = Counter({'Lorem Ipsum': 1}) │ │
│ │ pages_to_upload = [ │ │
│ │ │ Page(title='Lorem Ipsum', │ │
│ │ file_path=PosixPath('simple_labels.md'), │ │
│ │ page_id=None, parent_id=None, parent_title=None, │ │
│ │ space='~nate.woythaler', body='<h1>Lorem │ │
│ │ Ipsum</h1>\n<p>Lorem ipsum dolo [...]') │ │
│ │ ] │ │
│ │ postface_markup = '' │ │
│ │ preface_markup = '' │ │
│ │ something_went_wrong = False │ │
│ │ space_info = { │ │
│ │ │ 'id': 510328850, │ │
│ │ │ 'key': '~nate.woythaler', │ │
│ │ │ 'name': 'Nate Woythaler', │ │
│ │ │ 'homepage': { │ │
│ │ │ │ 'id': '515736001', │ │
│ │ │ │ 'type': 'page', │ │
│ │ │ │ 'status': 'current', │ │
│ │ │ │ 'title': 'Nate Woythaler’s Home', │ │
│ │ │ │ 'extensions': {'position': 'none'}, │ │
│ │ │ │ '_links': { │ │
│ │ │ │ │ 'webui': │ │
│ │ '/pages/viewpage.action?pageId=515736001', │ │
│ │ │ │ │ 'edit': │ │
│ │ '/pages/resumedraft.action?draftId=515736001', │ │
│ │ │ │ │ 'tinyui': '/x/wYG9Hg', │ │
│ │ │ │ │ 'self': │ │
│ │ 'https://${___CF_URL___}/rest/api/content/515736001' │ │
│ │ │ │ }, │ │
│ │ │ │ '_expandable': { │ │
│ │ │ │ │ 'container': │ │
│ │ '/rest/api/space/~nate.woythaler', │ │
│ │ │ │ │ 'metadata': '', │ │
│ │ │ │ │ 'operations': '', │ │
│ │ │ │ │ 'children': │ │
│ │ '/rest/api/content/515736001/child', │ │
│ │ │ │ │ 'restrictions': │ │
│ │ '/rest/api/content/515736001/restriction/byOperation… │ │
│ │ │ │ │ 'history': │ │
│ │ '/rest/api/content/515736001/history', │ │
│ │ │ │ │ 'ancestors': '', │ │
│ │ │ │ │ 'body': '', │ │
│ │ │ │ │ 'version': '', │ │
│ │ │ │ │ 'descendants': │ │
│ │ '/rest/api/content/515736001/descendant', │ │
│ │ │ │ │ ... +1 │ │
│ │ │ │ } │ │
│ │ │ }, │ │
│ │ │ 'type': 'personal', │ │
│ │ │ '_links': { │ │
│ │ │ │ 'webui': │ │
│ │ '/spaces/viewspace.action?key=~nate.woythaler', │ │
│ │ │ │ 'collection': '/rest/api/space', │ │
│ │ │ │ 'base': 'https://${___CF_URL___}', │ │
│ │ │ │ 'context': '', │ │
│ │ │ │ 'self': │ │
│ │ 'https://${___CF_URL___}/rest/api/space/~nate.woytha… │ │
│ │ │ }, │ │
│ │ │ '_expandable': { │ │
│ │ │ │ 'metadata': '', │ │
│ │ │ │ 'icon': '', │ │
│ │ │ │ 'description': '', │ │
│ │ │ │ 'retentionPolicy': '' │ │
│ │ │ } │ │
│ │ } │ │
│ │ tui = <md2cf.tui.Md2cfTUI object at 0x7f754273a590> │ │
│ │ upsert_page_result = None │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/natewo/Repositories/hack-kf-as-code/.venv/lib/python3.11/site-packages/md2cf/upsert.py:115 │
│ in upsert_page │
│ │
│ 112 │ │ if ( │
│ 113 │ │ │ not replace_all_labels │
│ 114 │ │ │ and page.labels │
│ ❱ 115 │ │ │ and labels_need_updating(page, existing_page) │
│ 116 │ │ ): │
│ 117 │ │ │ # print(f"Adding labels to page: {page.title} {page.labels}") │
│ 118 │ │ │ confluence.add_labels(page=existing_page, labels=page.labels) │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ action = <UpsertAction.UPDATED: 2> │ │
│ │ confluence = <md2cf.api.MinimalConfluence object at 0x7f75420936d0> │ │
│ │ existing_page = { │ │
│ │ │ 'id': '523021960', │ │
│ │ │ 'type': 'page', │ │
│ │ │ 'status': 'current', │ │
│ │ │ 'title': 'Lorem Ipsum', │ │
│ │ │ 'space': { │ │
│ │ │ │ 'id': 510328850, │ │
│ │ │ │ 'key': '~nate.woythaler', │ │
│ │ │ │ 'name': 'Nate Woythaler', │ │
│ │ │ │ 'type': 'personal', │ │
│ │ │ │ '_links': { │ │
│ │ │ │ │ 'webui': '/spaces/viewspace.action?key=~nate.woythaler', │ │
│ │ │ │ │ 'self': │ │
│ │ 'https://${___CF_URL___}/rest/api/space/~nate.woythaler' │ │
│ │ │ │ }, │ │
│ │ │ │ '_expandable': { │ │
│ │ │ │ │ 'metadata': '', │ │
│ │ │ │ │ 'icon': '', │ │
│ │ │ │ │ 'description': '', │ │
│ │ │ │ │ 'retentionPolicy': '', │ │
│ │ │ │ │ 'homepage': '/rest/api/content/515736001' │ │
│ │ │ │ } │ │
│ │ │ }, │ │
│ │ │ 'history': { │ │
│ │ │ │ 'latest': True, │ │
│ │ │ │ 'createdBy': { │ │
│ │ │ │ │ 'type': 'known', │ │
│ │ │ │ │ 'username': 'nate.woythaler', │ │
│ │ │ │ │ 'userKey': 'ff8080818151cd750185ba10895d025e', │ │
│ │ │ │ │ 'profilePicture': { │ │
│ │ │ │ │ │ 'path': '/download/attachments/462202994/user-avatar', │ │
│ │ │ │ │ │ 'width': 48, │ │
│ │ │ │ │ │ 'height': 48, │ │
│ │ │ │ │ │ 'isDefault': False │ │
│ │ │ │ │ }, │ │
│ │ │ │ │ 'displayName': 'Nate Woythaler', │ │
│ │ │ │ │ '_links': { │ │
│ │ │ │ │ │ 'self': │ │
│ │ 'https://${___CF_URL___}/rest/api/user?key=ff8080818151cd750185ba10895… │ │
│ │ │ │ │ }, │ │
│ │ │ │ │ '_expandable': {'status': ''} │ │
│ │ │ │ }, │ │
│ │ │ │ 'createdDate': '2023-11-13T16:32:16.531+01:00', │ │
│ │ │ │ '_links': { │ │
│ │ │ │ │ 'self': │ │
│ │ 'https://${___CF_URL___}/rest/api/content/523021960/history' │ │
│ │ │ │ }, │ │
│ │ │ │ '_expandable': { │ │
│ │ │ │ │ 'lastUpdated': '', │ │
│ │ │ │ │ 'previousVersion': '', │ │
│ │ │ │ │ 'contributors': '', │ │
│ │ │ │ │ 'nextVersion': '' │ │
│ │ │ │ } │ │
│ │ │ }, │ │
│ │ │ 'version': { │ │
│ │ │ │ 'by': { │ │
│ │ │ │ │ 'type': 'known', │ │
│ │ │ │ │ 'username': 'nate.woythaler', │ │
│ │ │ │ │ 'userKey': 'ff8080818151cd750185ba10895d025e', │ │
│ │ │ │ │ 'profilePicture': { │ │
│ │ │ │ │ │ 'path': '/download/attachments/462202994/user-avatar', │ │
│ │ │ │ │ │ 'width': 48, │ │
│ │ │ │ │ │ 'height': 48, │ │
│ │ │ │ │ │ 'isDefault': False │ │
│ │ │ │ │ }, │ │
│ │ │ │ │ 'displayName': 'Nate Woythaler', │ │
│ │ │ │ │ '_links': { │ │
│ │ │ │ │ │ 'self': │ │
│ │ 'https://${___CF_URL___}/rest/api/user?key=ff8080818151cd750185ba10895… │ │
│ │ │ │ │ }, │ │
│ │ │ │ │ '_expandable': {'status': ''} │ │
│ │ │ │ }, │ │
│ │ │ │ 'when': '2023-11-13T16:32:16.531+01:00', │ │
│ │ │ │ 'message': '', │ │
│ │ │ │ 'number': 1, │ │
│ │ │ │ 'minorEdit': False, │ │
│ │ │ │ 'hidden': False, │ │
│ │ │ │ '_links': { │ │
│ │ │ │ │ 'self': │ │
│ │ 'https://${___CF_URL___}/rest/experimental/content/523021960/version/1' │ │
│ │ │ │ }, │ │
│ │ │ │ '_expandable': {'content': '/rest/api/content/523021960'} │ │
│ │ │ }, │ │
│ │ │ 'ancestors': [], │ │
│ │ │ 'container': { │ │
│ │ │ │ 'id': 510328850, │ │
│ │ │ │ 'key': '~nate.woythaler', │ │
│ │ │ │ 'name': 'Nate Woythaler', │ │
│ │ │ │ 'type': 'personal', │ │
│ │ │ │ '_links': { │ │
│ │ │ │ │ 'webui': '/spaces/viewspace.action?key=~nate.woythaler', │ │
│ │ │ │ │ 'self': │ │
│ │ 'https://${___CF_URL___}/rest/api/space/~nate.woythaler' │ │
│ │ │ │ }, │ │
│ │ │ │ '_expandable': { │ │
│ │ │ │ │ 'metadata': '', │ │
│ │ │ │ │ 'icon': '', │ │
│ │ │ │ │ 'description': '', │ │
│ │ │ │ │ 'retentionPolicy': '', │ │
│ │ │ │ │ 'homepage': '/rest/api/content/515736001' │ │
│ │ │ │ } │ │
│ │ │ }, │ │
│ │ │ 'body': { │ │
│ │ │ │ 'storage': { │ │
│ │ │ │ │ 'value': '<h1>Lorem Ipsum</h1>\n<p>Lorem ipsum dolor sit │ │
│ │ amet</p>', │ │
│ │ │ │ │ 'representation': 'storage', │ │
│ │ │ │ │ '_expandable': {'content': '/rest/api/content/523021960'} │ │
│ │ │ │ }, │ │
│ │ │ │ '_expandable': { │ │
│ │ │ │ │ 'editor': '', │ │
│ │ │ │ │ 'view': '', │ │
│ │ │ │ │ 'export_view': '', │ │
│ │ │ │ │ 'styled_view': '', │ │
│ │ │ │ │ 'anonymous_export_view': '' │ │
│ │ │ │ } │ │
│ │ │ }, │ │
│ │ │ ... +3 │ │
│ │ } │ │
│ │ message = None │ │
│ │ minor_edit = False │ │
│ │ only_changed = False │ │
│ │ page = Page(title='Lorem Ipsum', file_path=PosixPath('simple_labels.md'), │ │
│ │ page_id=None, parent_id=None, parent_title=None, │ │
│ │ space='~nate.woythaler', body='<h1>Lorem Ipsum</h1>\n<p>Lorem ipsum │ │
│ │ dolo [...]') │ │
│ │ page_message = None │ │
│ │ replace_all_labels = False │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/natewo/Repositories/hack-kf-as-code/.venv/lib/python3.11/site-packages/md2cf/upsert.py:128 │
│ in labels_need_updating │
│ │
│ 125 │ │ return False │
│ 126 │ │
│ 127 │ if sorted( │
│ ❱ 128 │ │ [label.name for label in existing_page.metadata.labels.results] │
│ 129 │ ) != sorted(page.labels): │
│ 130 │ │ return True │
│ 131 │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ existing_page = { │ │
│ │ │ 'id': '523021960', │ │
│ │ │ 'type': 'page', │ │
│ │ │ 'status': 'current', │ │
│ │ │ 'title': 'Lorem Ipsum', │ │
│ │ │ 'space': { │ │
│ │ │ │ 'id': 510328850, │ │
│ │ │ │ 'key': '~nate.woythaler', │ │
│ │ │ │ 'name': 'Nate Woythaler', │ │
│ │ │ │ 'type': 'personal', │ │
│ │ │ │ '_links': { │ │
│ │ │ │ │ 'webui': '/spaces/viewspace.action?key=~nate.woythaler', │ │
│ │ │ │ │ 'self': 'https://${___CF_URL___}/rest/api/space/~nate.woythaler' │ │
│ │ │ │ }, │ │
│ │ │ │ '_expandable': { │ │
│ │ │ │ │ 'metadata': '', │ │
│ │ │ │ │ 'icon': '', │ │
│ │ │ │ │ 'description': '', │ │
│ │ │ │ │ 'retentionPolicy': '', │ │
│ │ │ │ │ 'homepage': '/rest/api/content/515736001' │ │
│ │ │ │ } │ │
│ │ │ }, │ │
│ │ │ 'history': { │ │
│ │ │ │ 'latest': True, │ │
│ │ │ │ 'createdBy': { │ │
│ │ │ │ │ 'type': 'known', │ │
│ │ │ │ │ 'username': 'nate.woythaler', │ │
│ │ │ │ │ 'userKey': 'ff8080818151cd750185ba10895d025e', │ │
│ │ │ │ │ 'profilePicture': { │ │
│ │ │ │ │ │ 'path': '/download/attachments/462202994/user-avatar', │ │
│ │ │ │ │ │ 'width': 48, │ │
│ │ │ │ │ │ 'height': 48, │ │
│ │ │ │ │ │ 'isDefault': False │ │
│ │ │ │ │ }, │ │
│ │ │ │ │ 'displayName': 'Nate Woythaler', │ │
│ │ │ │ │ '_links': { │ │
│ │ │ │ │ │ 'self': │ │
│ │ 'https://${___CF_URL___}/rest/api/user?key=ff8080818151cd750185ba10895d025e' │ │
│ │ │ │ │ }, │ │
│ │ │ │ │ '_expandable': {'status': ''} │ │
│ │ │ │ }, │ │
│ │ │ │ 'createdDate': '2023-11-13T16:32:16.531+01:00', │ │
│ │ │ │ '_links': { │ │
│ │ │ │ │ 'self': │ │
│ │ 'https://${___CF_URL___}/rest/api/content/523021960/history' │ │
│ │ │ │ }, │ │
│ │ │ │ '_expandable': { │ │
│ │ │ │ │ 'lastUpdated': '', │ │
│ │ │ │ │ 'previousVersion': '', │ │
│ │ │ │ │ 'contributors': '', │ │
│ │ │ │ │ 'nextVersion': '' │ │
│ │ │ │ } │ │
│ │ │ }, │ │
│ │ │ 'version': { │ │
│ │ │ │ 'by': { │ │
│ │ │ │ │ 'type': 'known', │ │
│ │ │ │ │ 'username': 'nate.woythaler', │ │
│ │ │ │ │ 'userKey': 'ff8080818151cd750185ba10895d025e', │ │
│ │ │ │ │ 'profilePicture': { │ │
│ │ │ │ │ │ 'path': '/download/attachments/462202994/user-avatar', │ │
│ │ │ │ │ │ 'width': 48, │ │
│ │ │ │ │ │ 'height': 48, │ │
│ │ │ │ │ │ 'isDefault': False │ │
│ │ │ │ │ }, │ │
│ │ │ │ │ 'displayName': 'Nate Woythaler', │ │
│ │ │ │ │ '_links': { │ │
│ │ │ │ │ │ 'self': │ │
│ │ 'https://${___CF_URL___}/rest/api/user?key=ff8080818151cd750185ba10895d025e' │ │
│ │ │ │ │ }, │ │
│ │ │ │ │ '_expandable': {'status': ''} │ │
│ │ │ │ }, │ │
│ │ │ │ 'when': '2023-11-13T16:32:16.531+01:00', │ │
│ │ │ │ 'message': '', │ │
│ │ │ │ 'number': 1, │ │
│ │ │ │ 'minorEdit': False, │ │
│ │ │ │ 'hidden': False, │ │
│ │ │ │ '_links': { │ │
│ │ │ │ │ 'self': │ │
│ │ 'https://${___CF_URL___}/rest/experimental/content/523021960/version/1' │ │
│ │ │ │ }, │ │
│ │ │ │ '_expandable': {'content': '/rest/api/content/523021960'} │ │
│ │ │ }, │ │
│ │ │ 'ancestors': [], │ │
│ │ │ 'container': { │ │
│ │ │ │ 'id': 510328850, │ │
│ │ │ │ 'key': '~nate.woythaler', │ │
│ │ │ │ 'name': 'Nate Woythaler', │ │
│ │ │ │ 'type': 'personal', │ │
│ │ │ │ '_links': { │ │
│ │ │ │ │ 'webui': '/spaces/viewspace.action?key=~nate.woythaler', │ │
│ │ │ │ │ 'self': 'https://${___CF_URL___}/rest/api/space/~nate.woythaler' │ │
│ │ │ │ }, │ │
│ │ │ │ '_expandable': { │ │
│ │ │ │ │ 'metadata': '', │ │
│ │ │ │ │ 'icon': '', │ │
│ │ │ │ │ 'description': '', │ │
│ │ │ │ │ 'retentionPolicy': '', │ │
│ │ │ │ │ 'homepage': '/rest/api/content/515736001' │ │
│ │ │ │ } │ │
│ │ │ }, │ │
│ │ │ 'body': { │ │
│ │ │ │ 'storage': { │ │
│ │ │ │ │ 'value': '<h1>Lorem Ipsum</h1>\n<p>Lorem ipsum dolor sit │ │
│ │ amet</p>', │ │
│ │ │ │ │ 'representation': 'storage', │ │
│ │ │ │ │ '_expandable': {'content': '/rest/api/content/523021960'} │ │
│ │ │ │ }, │ │
│ │ │ │ '_expandable': { │ │
│ │ │ │ │ 'editor': '', │ │
│ │ │ │ │ 'view': '', │ │
│ │ │ │ │ 'export_view': '', │ │
│ │ │ │ │ 'styled_view': '', │ │
│ │ │ │ │ 'anonymous_export_view': '' │ │
│ │ │ │ } │ │
│ │ │ }, │ │
│ │ │ ... +3 │ │
│ │ } │ │
│ │ page = Page(title='Lorem Ipsum', file_path=PosixPath('simple_labels.md'), │ │
│ │ page_id=None, parent_id=None, parent_title=None, space='~nate.woythaler', │ │
│ │ body='<h1>Lorem Ipsum</h1>\n<p>Lorem ipsum dolo [...]') │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'Bunch' object has no attribute 'metadata'
📄️ Lorem Ipsum ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ❌ Error while uploading
Total progress ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
... and the pip freeze output:
certifi==2023.7.22
chardet==5.1.0
charset-normalizer==3.3.2
commonmark==0.9.1
gitignorefile==1.1.2
idna==3.4
md2cf==2.3.0
mistune==0.8.4
Pygments==2.16.1
PyYAML==6.0.1
requests==2.31.0
rich==13.0.1
rich_argparse==1.0.0
urllib3==2.1.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels