Skip to content

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

Merged
gonchik merged 3 commits into
atlassian-api:masterfrom
R3gardless:fix/confluence-cloud-cql-search-v1
Oct 17, 2026
Merged

gonchik merged 3 commits into
atlassian-api:masterfrom
R3gardless:fix/confluence-cloud-cql-search-v1

Conversation

@R3gardless

Copy link
Copy Markdown
Contributor

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.
@gonchik
gonchik merged commit 93b9f38 into atlassian-api:master Oct 17, 2026
9 checks passed
@codecov

codecov Bot commented Oct 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.36%. Comparing base (5291abe) to head (792601b).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
atlassian/confluence/cloud/cloud.py 85.71% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1694      +/-   ##
==========================================
+ Coverage   65.35%   65.36%   +0.01%     
==========================================
  Files         107      107              
  Lines       19320    19327       +7     
  Branches     2102     2103       +1     
==========================================
+ Hits        12627    12634       +7     
  Misses       5998     5998              
  Partials      695      695              

☔ 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.

2 participants