Repository navigation
[Confluence] ConfluenceCloud: fix get_content_ancestors - #1711
Open
LuisFigueroaG wants to merge 1 commit into
Open
LuisFigueroaG wants to merge 1 commit into
LuisFigueroaG wants to merge 1 commit into
Conversation
Cloud.get_content_ancestors requests
/wiki/rest/api/content/{id}/ancestors, but the v1 content API has no
such endpoint, so the call always fails with a 404. Ancestors are only
available on the content itself through expand=ancestors.
Request /wiki/rest/api/content/{id}?expand=ancestors instead and return
the ancestors list, like the Server get_page_ancestors does. Extra
params passed by the caller are kept.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ConfluenceCloud.get_content_ancestors(content_id)(andConfluence(url="https://<site>.atlassian.net").get_content_ancestors(...)) sends:The Confluence Cloud v1 REST API doesn't have that endpoint (it isn't in the v1 content reference or in the v1 OpenAPI spec), so the call always fails with a 404. In v1, ancestors are only exposed on the content itself through
expand=ancestors(Content.ancestorsin the spec).This changes
get_content_ancestorsto:GET /wiki/rest/api/content/{id}?expand=ancestors, the same endpointget_page_by_id()andget_page_space()already use;ancestorslist (top-level page first, direct parent last), the same thing the Serverget_page_ancestors()returns. It returns[]for a top-level page;paramspassed by the caller and addexpand=ancestorsto them.Tests: replaced
test_get_content_ancestorsintests/confluence/test_confluence_cloud.py(it asserted the/ancestorspath) and added two tests, one for extra params and one that checks the final URL ishttps://test.atlassian.net/wiki/rest/api/content/123?expand=ancestors. The three tests fail on master. The full pytest suite, bandit and doc8 pass, black and flake8 are clean on the changed files, and mypy reports nothing forconfluence/cloud. I haven't run it against a real Confluence Cloud site.