Inability to save approval filter using save filter option

Description

Fix the error that prevents saving a selected approval filter when using the separate save filter option and displays the message failed to saved filter. Try again later.

Ensure the selected filter configuration is properly persisted and the error message is no longer triggered during a valid save action.

It’s on Jira and Confluence.


Steps to reproduce

  1. Navigate to the approvals section.

  2. Select and configure a filter.

  3. Click on the separate save filter option.

  4. Observe the displayed error message.

Expected behavior

  • The selected approval filter should be saved successfully.

  • No error message should be displayed during a valid save action.

  • The saved filter should be available for future selection.


Change

  • Saved filters are stored in the app database, one row per filter, instead of one shared app property per site. Atlassian caps that property at 32,768 characters, so after about 45 filters every save failed for everyone on the site.

  • Saving, editing and deleting change only that one filter. Limits: 100 filters per user in each list (Approvals, Definitions) and 50,000 per site. Reaching one shows which limit: "You have reached the limit of 100 saved filters per user in this list. Delete a filter first." or "This site has reached the limit of 50,000 saved filters. Delete a filter first."

  • Existing filters are copied from the property into the database the first time someone opens Saved filters (or an old page reads them) on the site after the release, in Jira and in Confluence. When the Forge property is absent, the copy reads the older Connect app property instead, so sites that moved from Connect late keep their filters. Only one copy runs per site at a time. The properties themselves are left untouched.

Decisions

  • Copy on the first request per site, not in a deploy-time job, so there is no burst of Atlassian calls across all sites at deploy. The property is read outside any database transaction and stored in one short one; a second request arriving meanwhile does not wait for it. If the copy fails (Atlassian unreachable, database error), it is rolled back and logged, and the site is retried after a minute. Until a site's copy has finished, the Saved filters dialog and the old route say that saved filters are being moved and to try again in a minute (with a Try again button in the dialog); saving a new filter still works.

  • Entries the new endpoints would reject (no id or owner, unknown list, empty or too long name, too long description, too many viewers, the NUL character, an id used twice with different content) are not copied and not shown. They stay in the property for manual recovery and are listed in the log. A filter whose viewers all pointed at nobody becomes Private, which is who could see it before.

  • Pages loaded before the release keep working: the old save route now reads the stored filters (the caller's own and the ones shared with them) and applies the caller's own creates, edits and deletes to the database. Other users' filters are never changed through it. Until a site's copy has finished, the old route answers that saved filters are being moved and to try again in a minute, so an old page never saves over filters it has not seen. It accepts at most 1,000 filters per save.

  • Only the owner can edit or delete a filter, and only administrators can share one, as in the current UI; the server now enforces both.

  • Filters shared with a group are returned only to members of one of those groups, checked on the server with the cached user-groups lookup the approval access checks already use. If the groups cannot be read, those filters are left out.

Fixes included

  1. Two users saving or deleting at the same time no longer lose each other's filters.

  2. A failed read of the saved filters no longer leads to the next save replacing all filters with one.

  3. Other users' private filters are no longer sent to the browser, and editing, deleting or sharing against the rules is refused by the server, not only hidden in the UI.

  4. Save and delete errors explain the cause (limit reached, sharing not allowed, invalid name or description, too many selected values or viewers) instead of a generic failure; the name and description fields stop at 255 and 2,000 characters.

  5. Filters shared with a group are no longer sent to users outside the group.

  6. Saved filters shared with a group show for its members as the server returns them; they no longer disappear when the browser cannot read the user's groups.

  7. Loading a saved filter in the Definitions list also restores its selected priorities.

Manual tester notes

  • Jira, on a site with saved filters from before the release: open Approvals, click Saved filters. The same filters as before are listed: your own, the ones shared with you or your organization, and none of other users' private filters. Same on Definitions.

  • Save a new filter on Approvals and another on Definitions (Save filter button). Each appears in its own Saved filters list, also after reloading the page.

  • Edit the name and description of your filter, then delete it. Changes stay after reload. Filters of other users show only the Apply action.

  • As a non-administrator, the Viewers section of Save filter shows Private only.

  • Save more than 50 filters on one site (Approvals and Definitions together). Every save succeeds.

  • In Save filter, type a name longer than 255 characters: the field stops at 255.

  • A filter shared with a group appears in Saved filters for a member of the group and not for a user outside it (Jira and Confluence).

  • If saved filters can't be loaded, the Saved filters dialog shows 'Saved filters could not be loaded' with the reason and a Try again button; check it fits the dialog.

  • Repeat the first three steps in Confluence.

  • Definitions list: save a filter with a definition and a priority, clear the filters, load the saved filter: both are selected and the list is filtered by both.

Before release

  • Deploy the backend (Liquibase changeset saved-filters creates table saved_filter) before the Forge frontend. From the backend deploy on, old pages read and write the database through the old route, so nothing waits for the frontend.

  • Watch the logs: INFO Copied saved filters of host N from the app property: X parsed, Y inserted, Z left in the property once per site; WARN Saved filters of host N left in the app property because they cannot be copied (entries to recover by hand); WARN Reading the saved filters app property of host N failed, next try in 60 s and Storing the saved filters copied from the app property of host N failed (should stop after a retry; one repeating every minute for the same host needs a look, old pages and the Saved filters dialog on that site show the try-again message meanwhile); WARN Reading the groups of user X on host N failed, saved filters shared with groups are left out.

  • Progress: select count(*) from host_migration where migration_id = 'copySavedFiltersFromAppProperty'; select count(*) from saved_filter.

  • Backend rollback: the old backend reads the untouched property again, so filters show as before the release, but filters created, edited or deleted after the release are not in it, and filters saved during the rollback go only to the property. After rolling forward, re-run the copy by deleting the copySavedFiltersFromAppProperty rows from host_migration: filters saved during the rollback are added, existing rows are kept as they are, and filters deleted in the database since the first copy come back.

  • Later cleanup (AP-2558), a release or two after the frontend is everywhere: delete the ap-saved-filters properties and remove the old route handling (LegacySavedFilterRoute).