Skip to content

Confluence Cloud: run CQL search against the v1 endpoint - #1694

Open
R3gardless wants to merge 3 commits into
atlassian-api:masterfrom
R3gardless:fix/confluence-cloud-cql-search-v1
Open

R3gardless wants to merge 3 commits into
atlassian-api:masterfrom
R3gardless:fix/confluence-cloud-cql-search-v1

Conversation

@R3gardless

Copy link
Copy Markdown

Problem

ConfluenceEndpoints.V2["search"] is api/v2/search, and every search helper on the Cloud client goes through it: search(), iter_cql(), cql_all(), search_content() and get_space_content().

The Confluence Cloud v2 API has no search endpoint. Atlassian's v2 OpenAPI spec (https://dac-static.atlassian.com/cloud/confluence/openapi-v2.v3.json, info.version 2.0.0) defines no path containing search, and CQL search is documented only under the v1 API (GET /wiki/rest/api/search). So these calls cannot succeed against Cloud today.

Change

  • ConfluenceEndpoints.V2["search"] → rest/api/search (still served on Cloud).
  • _search_params() now builds what the v1 endpoint accepts:
    • free text query → cql clause text ~ "<query>" (quotes escaped);
    • query together with cql → the clause is ANDed into the expression, inserted before a trailing ORDER BY so expressions built by get_space_content() stay valid;
    • excerpt=False → excerpt=none (the v1 parameter is an enum, not a boolean);
    • body_format → expand=content.body.<format> (v1 has no body-format parameter).
  • Public signatures are unchanged, and cursor pagination through _get_paged() keeps working: the v1 search response carries a relative _links.next with the cursor in its query string.

Tests

  • Updated the endpoint expectations in tests/test_confluence_v2.py (test_search, test_search_with_cql) and tests/confluence/test_confluence_cloud.py (test_iter_cql_follows_all_result_pages, test_iter_cql_supports_text_query).
  • Added test_iter_cql_combines_cql_and_text_query_before_order_by and test_iter_cql_maps_body_format_to_expand.
  • Full suite: 1753 passed, 10 skipped.

Note

This is independent of #1693 (label writes), which fixes the same class of problem for /pages/{id}/labels. Either can be merged first.

The Confluence Cloud v2 API has no search endpoint, so search(), iter_cql(),
cql_all(), search_content() and get_space_content() were all calling
api/v2/search, which does not exist.

Point the search endpoint at v1 rest/api/search and translate the arguments
to what it accepts: a free text query becomes a text ~ CQL clause (added
before a trailing ORDER BY when a CQL expression is given too), excerpt=False
becomes excerpt=none and body_format becomes expand=content.body.<format>.
Codacy's Prospector run flags the summary position and the Google style
Raises section, so state the error behaviour in prose instead.

This branch has not been deployed

No deployments
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