fix(labels): handle missing metadata and fix add_labels serialization#59
fix(labels): handle missing metadata and fix add_labels serialization#59geopanther wants to merge 1 commit into
Conversation
Fix two label-related edge cases: 1. add_labels() used data= (form-encoded) instead of json= for the label payload, causing failures on some Confluence versions 2. labels_need_updating() crashed with AttributeError when page metadata.labels.results was absent (e.g., new pages without labels) Adapted from iamjackg/md2cf#118 by @nate-woythaler.
Maintainer ReviewVerdict: ✅ Approve Both fixes address real bugs that would hit users of self-hosted Confluence or pages created before labels were supported.
vs upstream: Our approach is cleaner — upstream switched to dict-style access ( No concerns. Ship it. |
Summary
Fix two label-related edge cases that cause crashes on some Confluence server versions.
Adapted from iamjackg/md2cf#118 by @nate-woythaler.
Changes
add_labels(): Changed fromdata=(form-encoded) tojson=for proper JSON serialization of label payloadslabels_need_updating(): Added defensivegetattrchain to handle pages withoutmetadata.labels.results— treats missing metadata as 'needs update'Differences from upstream
labels_need_updating()to use dict-style.get()access, which breaks the existing Bunch-based object model. We usegetattrchains instead, preserving compatibility with the Bunch response objectsjson.dumps()wrapper forupdate_pagelabels is unnecessary sincerequestshandles JSON serialization via thejson=parameter — omitted# return self.api.content(page.id).post(commentTests
test_labels_need_updating_when_no_metadata