PDF step: attach the PDF to the Confluence page

Description

Goal

In Confluence, the PDF step (AP-541) can attach the PDF to the page, as it attaches it to the work item in Jira.

Background

Uploading a page attachment needs the Confluence scope write:confluence-file, which the app does not have: AP-541's live check failed with "Unauthorized; scope does not match", so AP-541 ships Confluence as email only. Adding a scope makes a major version that every site admin must accept, so this ships with the next planned Confluence permission change.

Verified on 2026-11-17 on the dev Confluence app (environment mb-dev, Forge CLI 13.0.0):

  • A version adding write:confluence-file cannot be rolled out without admin consent: forge version bulk-upgrade refuses it with "Target version has privilege escalation due to additional scopes compared to the source version." (PRIVILEGE_ESCALATION_ROLLOUT), although the app already has write:confluence-content.

  • The granular write:attachment:confluence is refused the same way.

  • A version with the same scopes as before is rolled out without consent, so only the new scope blocks it.

  • Forge compares the scopes of the two versions. The production manifest is generated from the same apfc.js (no Connect scopes such as write:connect-confluence), so production behaves the same.

Change

  • Add write:confluence-file to the Confluence app (extra/forge-dev/apps/apfc.js).

  • Show "Attach to the page" in the Confluence PDF step form, and allow attachEnabled for pages in PdfStepValidator and the Confluence Web API schema.

  • Upload with Confluence.addAttachment under the app's identity (as document-sign does), with the same file name as in Jira, and show "Attached <file name>" on the step.

  • Sites that have not accepted the new version yet: an upload refused for the missing scope shows a clear step error and Instance error ("Accept the latest app version to attach PDFs to pages") instead of the raw response.

Acceptance criteria

  • A Confluence PDF step with "Attach to the page" adds the PDF to the page's attachments, and the step shows its file name.

  • On a site without the new scope, the step shows the clear error and the approval goes on (unless the reject option is on).

Before release

  • Ships with the next Confluence permission change: new scope, major version, admins accept it. Installations whose admin has not accepted stay on the previous major version, and Atlassian does not email their admins, so plan how admins are told.