Skip to content

fix(confluence): pass expand param correctly in get_page_space() - #1665

Open
mrcrysta1 wants to merge 1 commit into
atlassian-api:masterfrom
mrcrysta1:fix/confluence-get-page-space-expand-param
Open

fix(confluence): pass expand param correctly in get_page_space()#1665
mrcrysta1 wants to merge 1 commit into
atlassian-api:masterfrom
mrcrysta1:fix/confluence-get-page-space-expand-param

Conversation

@mrcrysta1

Copy link
Copy Markdown
Contributor

Summary

Fixes #1663

get_page_space() in Confluence Server passes expand="space" as a keyword argument to self.get(), but AtlassianRestAPI.get() does not accept expand as a keyword — it expects it inside a params dict. This causes a TypeError: AtlassianRestAPI.get() got an unexpected keyword argument 'expand' on Confluence Server v5.0.0+.

Changes

  • atlassian/confluence/server/__init__.py: Updated get_page_space() to build a params dict with expand and pass it to self.get() directly, matching the pattern used by get_page_by_id() in the same file.
  • tests/confluence/test_confluence_server.py: Updated existing test assertion and added 2 new tests for edge cases (page with no space, page with empty space object).

Testing

All 156 Confluence Server tests pass:

tests/confluence/test_confluence_server.py::TestConfluenceServer::test_get_page_space PASSED
tests/confluence/test_confluence_server.py::TestConfluenceServer::test_get_page_space_no_space PASSED
tests/confluence/test_confluence_server.py::TestConfluenceServer::test_get_page_space_empty_space PASSED

Root Cause

The call chain is:

get_page_space(page_id)
  -> get_content(page_id, expand="space")
    -> self.get(f"content/{content_id}", **kwargs)  # expand="space" becomes a bare kwarg

But self.get() only accepts params as a dict for query parameters. The fix short-circuits get_content() and calls self.get() with the correct params={"expand": "space"} pattern.

This issue was introduced in the v5.0.0 Cloud/Server split.


AI assistance used: code exploration, test generation, and commit message drafting.

get_page_space() passed expand='space' as a keyword argument to
self.get(), but AtlassianRestAPI.get() does not accept expand as a
keyword — it expects it inside a params dict. This caused a TypeError
when calling get_page_space() on Confluence Server v5.0.0+.

Fix by building a params dict and passing it to self.get() directly,
matching the pattern used by get_page_by_id() in the same file.

Fixes atlassian-api#1663
@codecov

codecov Bot commented Aug 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.57%. Comparing base (6f49a1a) to head (9721912).
⚠️ Report is 27 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1665      +/-   ##
==========================================
+ Coverage   59.74%   60.57%   +0.83%     
==========================================
  Files         101      106       +5     
  Lines       16868    18047    +1179     
  Branches     1746     1842      +96     
==========================================
+ Hits        10077    10932     +855     
- Misses       6393     6655     +262     
- Partials      398      460      +62     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

[ConfluenceServer] TypeError when calling get_page_space() in version >5.0.0

1 participant