Skip to content

[Confluence] Fix pagination for get_all_* methods and unify _get_paged across Cloud/Server#1616

Open
Zircoz wants to merge 1 commit intoatlassian-api:masterfrom
Zircoz:master
Open

[Confluence] Fix pagination for get_all_* methods and unify _get_paged across Cloud/Server#1616
Zircoz wants to merge 1 commit intoatlassian-api:masterfrom
Zircoz:master

Conversation

@Zircoz
Copy link

@Zircoz Zircoz commented Feb 15, 2026

Summary

Fixes #1598
Fixes #1480

Multiple get_all_* methods (get_all_pages_from_space, get_all_pages_from_space_trash, get_all_draft_pages_from_space, etc.) only returned the first page of results because they called self.get() directly instead of self._get_paged(). Additionally, pagination broke when the Confluence API returned _links.next as a plain URL string rather than a {"href": "..."} dict.

Changes

Pagination fix (core issue)

  • Switch 10 get_all_* methods to use _get_paged on both Server and Cloud, so they now return fully-paginated generators instead of single-page dicts
  • Unify _get_paged into ConfluenceBase — removed duplicate implementations from ConfluenceCloudBase and ConfluenceServerBase, replacing them with a single method in the shared base class that handles both str and dict formats for _links.next
  • Fix relative pagination URLs — when the API returns a relative path (e.g. /rest/api/content?cursor=1), the base URL is now correctly prepended by stripping the api_root suffix, preserving Cloud API gateway routing prefixes

Cloud URL/routing fixes

  • Fix Cloud api_root from wiki/api/v2 to wiki/rest/api — the previous default was incorrect: every endpoint in the Cloud class uses v1 REST API paths (content/{id}, space/{id}, content/search?cql=, etc.), but they were being prefixed with the v2 base path (wiki/api/v2). The v2 API has an entirely different resource model (pages/{id}, spaces/{id}, no CQL search) so the old configuration produced invalid URLs. This is a bugfix, not a v2→v1 downgrade.
  • Recognize api.atlassian.com in Cloud detection — the Confluence wrapper now correctly routes OAuth2 API gateway URLs to ConfluenceCloud
  • Support explicit cloud= kwarg — allows users to force Cloud or Server routing regardless of URL heuristics

Tests

  • New test_confluence_routing.py — covers .atlassian.net, .jira.com, api.atlassian.com, self-hosted URLs, and explicit cloud=True/False override
  • Pagination edge-case tests for both Cloud and Server: string next link, dict next link, missing href, None next link, no results key, and relative next link resolution
  • Updated existing tests to expect generator return values from get_all_* methods

Breaking change

get_all_pages_from_space, get_all_blog_posts_from_space, get_all_pages_by_label, get_all_blog_posts_by_label, get_all_draft_pages_from_space, get_all_draft_blog_posts_from_space, get_trash_content, get_all_pages_from_space_trash, and get_all_blog_posts_from_space_trash now return generators (from _get_paged) instead of dicts. Callers that accessed result["results"] must switch to iterating the return value directly (e.g. list(result)).

Test plan

  • pytest tests/confluence/ — all new and updated tests pass
  • Verify get_all_pages_from_space returns all pages (not just first 25) on a Confluence Server instance with >25 pages
  • Verify the same on Confluence Cloud
  • Verify Cloud OAuth2 gateway URLs (api.atlassian.com/ex/confluence/...) route and paginate correctly

🤖 Generated with Claude Code

@Zircoz Zircoz changed the title [Confluence] Fix get_all_pages_from_space pagination #1598 [Confluence] Fix pagination for get_all_* methods and unify _get_paged across Cloud/Server Feb 15, 2026
@Zircoz Zircoz force-pushed the master branch 2 times, most recently from 8c2f7f9 to ea2fa33 Compare February 15, 2026 18:36
@Zircoz Zircoz marked this pull request as ready for review February 15, 2026 18:37
…d across Cloud/Server

Fixes atlassian-api#1598
Fixes atlassian-api#1480

- Switch 10 get_all_* methods to use _get_paged for full pagination
- Unify _get_paged into ConfluenceBase (remove Cloud/Server duplicates)
- Handle _links.next as both string and dict formats
- Fix relative pagination URLs by prepending base URL correctly
- Fix Cloud api_root from wiki/api/v2 to wiki/rest/api (endpoints use v1 paths)
- Recognize api.atlassian.com in Cloud detection; support explicit cloud= kwarg
- Add routing tests and pagination edge-case tests for both Cloud and Server

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Confluence bug: get_all_pages_from_space only loads first page The Confluence.get_all_pages_from_space() implementation is wrong.

1 participant