CQL search by approval state returns no pages in Approval Path for Confluence

Description

Problem

Approval Path for Confluence stores the approval state on every page with an approval (definitions, pending approvers, group decisions). This data should be available in CQL search, the same way Approval Path for Jira exposes it in JQL. Today a CQL query on any of these fields returns no pages. Users cannot find, for example, pages waiting for a given person's decision or pages approved in a given definition, and Automation for Confluence rules based on such a query do not work. The problem affects only Approval Path for Confluence and has existed since the module migration to Forge (February 2026).

Cause

The search index is configured for a field the app does not store. The fields actually stored on the page are not indexed, so Confluence has nothing to search.

Steps to reproduce

  1. On a Confluence page, start an approval with a User step where user A is the approver.

  2. In Confluence advanced search (CQL), search for pages where A is a pending approver.

Actual behavior

The search does not return the page from step 1.

Expected behavior

Pages can be searched with CQL by the same data that Approval Path for Jira exposes in JQL:

  • definitions started on the page, approved, rejected and in progress,

  • pending approvers (users, groups and external approvers by email, in the current step and in all steps),

  • groups that approved or rejected.

CQL fields have the same names as the JQL fields in Approval Path for Jira, e.g. pendingApproverAccountId, approvedDefinitionId. Pages with approvals started before the fix are searchable too.

Acceptance criteria

  • A page where user A has a pending decision is returned by the CQL search pendingApproverAccountId = "<accountId of A>".

  • A page is returned by CQL search by definition ID for started, approved, rejected and in-progress definitions, each according to its state.

  • A page with an Email step is returned by CQL search by the email of a pending external approver.

  • After a decision (approve, reject), CQL results change according to the new approval state.

  • A page with an approval started before the fix was deployed is returned by CQL search.

  • CQL results contain only pages the user is allowed to view.

  • The Approval Path for Confluence documentation describes the available CQL fields and gives example queries.

Change

  • Confluence search now indexes the approval data stored on each page, under the same field names as the JQL fields of Approval Path for Jira: definitionId, approvedDefinitionId, rejectedDefinitionId, pendingDefinitionId, pendingApproverAccountId, pendingApproverGroupName, pendingApproverExternalEmail, pendingApproverAccountIdAllSteps, approvedApproverGroupName, rejectedApproverGroupName. Example: pendingApproverAccountId = "<accountId>". Each value of a field matches exactly; =, != and IN (...) work, and ids may be quoted or not. Confluence rejects NOT IN on app search fields (a Confluence error, also on empty fields); use type = page AND NOT (field IN (...)) or chained != instead.

  • Pages store definition ids as text so that Confluence can search them with IN and quoted values, and external approver emails in lowercase, so pendingApproverExternalEmail queries must use the lowercase address (for example pendingApproverExternalEmail = "jane.doe@example.com"), whatever capitals the Email step uses.

  • Pages with approvals started before the release are re-indexed automatically, once per site: up to about 30 minutes after the app update reaches the site, the app rewrites the approval data of all its pages. Confluence only indexes data written after the new search fields are live, and drops writes made right after the switch, so the app waits 10 minutes after it first sees the new fields.

Decisions

  • In the QA and local apps the field names end with the environment suffix (pendingApproverAccountIdQa), because Confluence requires search field names to be globally unique. Production uses the plain names.

  • In Confluence every field is indexed as text: CQL number fields reject IN, NOT IN and quoted values. Range operators on definition ids are not available in CQL (JQL keeps them).

  • External approver emails are stored in lowercase in Confluence: Confluence text fields match exactly, and one rule (write the address in lowercase) is simpler than matching how each step spells it.

Fixes included

  1. Pages now store the approvers awaited in all active steps (needed for pendingApproverAccountIdAllSteps).

  2. When an approval's validity expires, the page's search data is refreshed, as it already was in Jira.

  3. An approval made outdated by a page edit no longer counts as pending, and its approvers and group decisions no longer appear in the search data. Before, a decision on another approval of the same page brought the outdated approval's approvers back.

  4. The page re-index marks a site done only when no page failed. A site with failed pages is retried at the next 15-minute run, at most 3 rewrite rounds; after that it is marked done with one WARN naming the failed count, and those pages become searchable after their next approval change.

  5. A site check rejected with a 4xx error is logged at INFO without a stack trace; other failures stay WARN.

  6. Restoring an archived approval that was already outdated no longer puts its approvers into the approvers awaited on the page, so a pending-for-me CQL search does not find a page the user cannot decide on.

Manual tester notes

  • On QA Confluence, start an approval with a User step for user A on a page. Open <site>/wiki/rest/api/search?cql=pendingApproverAccountIdQa="<A's account ID>" in the browser (the account ID is in A's profile URL). The page is listed.

  • definitionIdQa=<definition ID> and pendingDefinitionIdQa=<definition ID> list the page.

  • definitionIdQa IN (<id1>, <id2>) and definitionIdQa = "<id>" list the page.

  • After A approves the last step, approvedDefinitionIdQa=<definition ID> lists the page and the pendingApproverAccountIdQa search no longer does. After a rejection, rejectedDefinitionIdQa=<definition ID> lists it.

  • With an Email step, pendingApproverExternalEmailQa="<email in lowercase>" lists the page.

  • With an Email step whose address has capitals, pendingApproverExternalEmailQa = "<address in lowercase>" lists the page.

  • With a Group step, pendingApproverGroupNameQa="<group>" and pendingApproverAccountIdAllStepsQa="<member's account ID>" list the page. After the group approves, approvedApproverGroupNameQa="<group>" lists it.

  • A page whose approval was started before the deploy is listed too, at most about 30 minutes after the app update reached the site.

  • A user who cannot view the page does not get it in the results.

  • Archive and unarchive an approval with a pending User step for A on a page: after unarchiving, the pendingApproverAccountIdQa search lists the page again.

Before release

  • Deploy the Forge manifest of Approval Path for Confluence. The re-index needs no manual step; once the new version reaches the sites, the backend log shows #M28 [host:N] Rewrote the approval property of X pages per site.

  • If the Forge deploy rejects a search field name as already taken, stop and pick a prefixed name.

  • After deploying the backend and the Confluence app, each site logs #M28 [host:N] Rewrote the approval property of X pages once the new search index is live; until then a CQL search by approval state finds only pages changed after the deploy.