Skip to content

[dev] [Marfuen] mariano/fix-policy-pdf-upload-multipart#2946

Merged
Marfuen merged 9 commits into
mainfrom
mariano/fix-policy-pdf-upload-multipart
May 28, 2026
Merged

[dev] [Marfuen] mariano/fix-policy-pdf-upload-multipart#2946
Marfuen merged 9 commits into
mainfrom
mariano/fix-policy-pdf-upload-multipart

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented May 28, 2026

This is an automated pull request to merge mariano/fix-policy-pdf-upload-multipart into dev.
It was created by the [Auto Pull Request] action.


Summary by cubic

Add multipart/form-data support to POST /policies/:id/pdf and align DELETE /policies/:id/pdf with version rules. Both endpoints default to the latest draft version and drop the legacy policy-level path so PDFs behave consistently in the UI.

  • New Features

    • Accept multipart PDF uploads via FileInterceptor('file'); JSON base64 still supported.
    • OpenAPI updated with @ApiConsumes and @ApiBody to document both upload paths.
  • Bug Fixes

    • POST and DELETE default to the latest draft when versionId is missing; 400 if none.
    • Validate base64 input (URL-safe, unpadded); sanitize names and use the uploaded file’s MIME type.
    • Enforce version guards (reject published/pending).
    • Always update both version and policy pdfUrl, remove legacy policy-level paths; set policy displayFormat to 'PDF' on upload and 'EDITOR' on delete.

Written for commit d71e701. Summary will update on new commits.

Review in cubic

Marfuen and others added 4 commits May 28, 2026 11:21
The endpoint previously only accepted JSON with base64-encoded file data,
causing a 500 when customers sent a raw PDF. Now supports both multipart/
form-data (direct file upload) and the existing JSON approach.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Buffer.from(str, 'base64') silently ignores invalid characters, so
malformed payloads would upload corrupted files to S3. Now rejects
invalid base64 early with a clear 400 error.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The base64 validator was stricter than Node's Buffer.from decoder,
rejecting url-safe chars (-_) and unpadded input that previously worked.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When uploading via API without a versionId, the PDF was stored at the
policy level only. The UI reads pdfUrl from the version, so the PDF
appeared missing. Now defaults to the current version so the PDF shows
in the UI immediately.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Ready Ready Preview, Comment May 28, 2026 5:43pm
comp-framework-editor Ready Ready Preview, Comment May 28, 2026 5:43pm
portal Ready Ready Preview, Comment May 28, 2026 5:43pm

Request Review

…icy-level path

Every policy has a currentVersionId since v1 is created on policy
creation. Uploading to the policy level was dead code that the UI
couldn't display. Now defaults to currentVersion when no versionId
is provided, with a single unified code path.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel vercel Bot temporarily deployed to Preview – portal May 28, 2026 17:36 Inactive
@vercel vercel Bot temporarily deployed to Preview – app May 28, 2026 17:36 Inactive
When no versionId is provided, find the latest unpublished draft
version instead of blindly using currentVersionId (which may be
published and would reject the upload).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel vercel Bot temporarily deployed to Preview – portal May 28, 2026 17:37 Inactive
@vercel vercel Bot temporarily deployed to Preview – app May 28, 2026 17:37 Inactive
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel vercel Bot temporarily deployed to Preview – app May 28, 2026 17:37 Inactive
@vercel vercel Bot temporarily deployed to Preview – portal May 28, 2026 17:37 Inactive
DELETE /pdf had the same issues as the upload endpoint: no published-
version guard and a legacy policy-level fallback. Now defaults to the
latest draft version and rejects deletes on published/pending versions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel vercel Bot temporarily deployed to Preview – app May 28, 2026 17:38 Inactive
@vercel vercel Bot temporarily deployed to Preview – portal May 28, 2026 17:38 Inactive
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Marfuen Marfuen merged commit 7e38617 into main May 28, 2026
8 of 10 checks passed
@Marfuen Marfuen deleted the mariano/fix-policy-pdf-upload-multipart branch May 28, 2026 17:42
@claudfuen
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.65.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants