Skip to content

feat(metadata): list Confluence labels and content statuses - #1274

Open
BenjaminShinar wants to merge 11 commits into
kovetskiy:masterfrom
BenjaminShinar:metadata_listing_label_statuses
Open

BenjaminShinar wants to merge 11 commits into
kovetskiy:masterfrom
BenjaminShinar:metadata_listing_label_statuses

Conversation

@BenjaminShinar

@BenjaminShinar BenjaminShinar commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Feature request: #1307

This PR lays the groundwork for letting mark set Confluence page statuses, similar to how it sets labels.
It adds API methods and CLI commands for reading and listing labels and content statuses.

These commands are useful independently: they let users inspect labels and statuses before choosing what to apply.

Summary

  • Add experimental metadata labels list and metadata statuses list commands.
  • Show tables by default, with --json for scripting.
  • Accept IDs or supported Confluence URLs through --page, --blogpost, --attachment, and --custom-content.
  • Distinguish labels used inside a space (--in-space KEY) from labels attached to the space itself (--space KEY).
  • Share URL parsing between metadata, export, and page commands through the confluence package.

How to read this PR

  1. docs/metadata_cli.md describes the selectors and output formats; util/metadata.go implements the commands.
  2. confluence/metadata.go contains the listing API methods and their result types.
  3. confluence/contenturl.go parses URLs; confluence/content.go resolves references that require an API lookup.
  4. ListLabels calls upstream’s walkV2 directly and returns an error on a first-page 404.
  5. The metadata and URL tests cover routing, parsing, pagination, output, and failures.

Approach

Selectors must be explicit command-line arguments.
Configured publishing-space settings do not silently narrow a metadata listing.
URL selectors supply the instance when no base URL is configured.
A conflicting configured instance is rejected before resolving credentials or making requests.

Browser attachment download URLs supply the parent content ID and filename.
The resolver uses the existing attachment-listing method to look up the ID.
API download URLs supply the attachment ID directly.
Title-based page and blog URLs use a lookup constrained to the selected content type.

Files changed

  • util/metadata.go defines the commands, validates selectors, prepares authentication, and writes tables or JSON.
  • util/cli.go registers metadata and uses the shared parser for export URLs.
  • confluence/metadata.go adds label queries and methods for space, personal, and assigned content statuses.
  • confluence/contenturl.go contains PageRef and ParsePageURL, moved from export, plus content URL parsing.
  • confluence/content.go adds API.ResolveContentID for title-based and attachment-filename lookups.
  • confluence/v2pages.go shares label decoding and the label page size.
  • export/url.go retains export-specific rules for rewriting page links; export/page.go uses the relocated reference type.
  • util/page.go uses the relocated parser for page commands.
  • confluence/instance.go and its example and tests reference the parser in its shared location.
  • confluence/contenturl_test.go contains the moved page URL tests and additional content URL tests.
  • export/convert_test.go uses the shared reference type; its parser tests move with the parser.
  • confluence/metadata_test.go covers invalid collections and missing IDs without sending requests.
  • util/metadata_test.go covers selectors, URL resolution, credentials, pagination, gateway paths, output, and failures.
  • cmd/mark/metadata_test.go checks production-entry-point exit codes and output streams on request failures.
  • docs/metadata_cli.md documents the interface; README.md links to it and includes metadata in root help.

Interfaces

Content selectors accept IDs or URLs: --page, --blogpost, --attachment, and --custom-content.
Label space selectors take space keys: --in-space searches content labels, while --space lists space-object labels.
Status listings retain --space, --personal, and --page.

export.PageRef and export.ParsePageURL move to confluence.PageRef and confluence.ParsePageURL.
Their page URL parsing behavior is preserved.

Automated tests

  • Parser tests cover page and blog URLs, short links, attachment previews and downloads, custom-content links, and malformed references.
  • CLI tests check space-scope routing, URL-derived instances, instance mismatches, and type-specific title lookups.
  • Attachment lookup tests cover missing files and authorization failures without issuing a subsequent label request.
  • Listing tests cover pagination, gateway paths, populated and empty results, configuration precedence, and output-write failures.
  • Subprocess tests check exit code 1, stderr diagnostics, and empty stdout on request failures.

Validation

  • Affected parser and metadata race tests passed.
  • GitHub CI passed at f5a596f, including the full race-enabled suite and the standard Docker image build. CI run
  • Go lint, Markdown lint, the README/help consistency check, and the custom binary build passed.
  • Live Confluence Cloud checks on November 15, 2026 covered the original label and status listing scopes.
  • Live Confluence Cloud checks on November 18, 2026 matched URL and ID listings for pages, blogs, attachments, and custom content. Page status and table output matched too.
  • URL-derived instances worked with an explicitly cleared base URL. Conflicting instances, missing pages, and missing attachment filenames failed with empty stdout.
  • Confluence Server and Data Center were not tested live.

The personal-status listing reports user-created statuses returned by Confluence's API.
It may differ from the web UI's custom-status list; UI removal and API deletion semantics have not been established.

Design questions

  • metadata overlaps with Mark's term for metadata inside Markdown files.
  • Tables serve interactive use and --json serves scripts; feedback on consistency with other Mark commands is welcome.
  • Label output retains Confluence's prefix terminology and values.

Out of scope

  • Adding, assigning, updating, or removing labels and statuses.
  • Reverse label lookups: finding content by label.

Setting page statuses is planned as a separate follow-up.

AI assistance

This PR was developed with Codex assistance using GPT 6.1 Sol with medium reasoning effort.

@BenjaminShinar
BenjaminShinar marked this pull request as ready for review November 15, 2026 08:58
@BenjaminShinar
BenjaminShinar force-pushed the metadata_listing_label_statuses branch 2 times, most recently from 735a1bd to 8da1082 Compare November 18, 2026 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant