[dev] [Marfuen] mariano/fix-policy-pdf-upload-multipart#2946
Merged
Conversation
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>
…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>
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>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
🎉 This PR is included in version 3.65.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
FileInterceptor('file'); JSON base64 still supported.@ApiConsumesand@ApiBodyto document both upload paths.Bug Fixes
versionIdis missing; 400 if none.pdfUrl, remove legacy policy-level paths; set policydisplayFormatto 'PDF' on upload and 'EDITOR' on delete.Written for commit d71e701. Summary will update on new commits.
Review in cubic