Skip to content

fix(api): detect multipart file uploads and reject truncated batches (#9435) - #9452

Merged
vitormattos merged 7 commits into
mainfrom
fix/9435-multipart-upload-count
Nov 14, 2026
Merged

vitormattos merged 7 commits into
mainfrom
fix/9435-multipart-upload-count

Conversation

@vitormattos

@vitormattos vitormattos commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Scope

Partial LibreSign-side fix for #9435. This is not a replacement for nextcloud/openapi-extractor#401 and does not claim complete multipart OpenAPI generation.

  • Move getUploadedFile('files') / getUploadedFile('file') into FileController::save(), preserving the existing JSON/reference fallback and routing behavior. The upstream extractor's proposed direct-call detection can now see these accesses.
  • Add an optional expectedFilesCount multipart field check in file-save and file-add-file-to-envelope, executed after validation/normalization but before storage. A mismatch (e.g., a PHP max_file_uploads truncation) produces the existing 422 error response; omitted values remain accepted for existing clients.
  • Have both UI upload paths send the expected count: RequestPicker creates files/envelopes and EnvelopeFilesList appends files to existing envelopes. Existing file and files[] field names remain unchanged.
  • Add a focused PHP unit data provider (11 cases including missing/invalid/mismatched counts) and frontend unit assertions for single/two-file requests.

Compatibility and security

  • No change to routes, operation IDs, permissions, PDF validation, or saved JSON/reference formats.
  • The count assertion is client-reported and backward-compatible; it detects accidental truncation for clients that send it, not malicious underreporting.
  • All validation occurs before creation of new files or envelope children.
  • Does not change test(sdk): evaluate typescript axios client compatibility #9437's disposable generated-client evaluation, especially the existing anyOf No-Go.

Verification

  • All three commits are signed and DCO matches their author; Git Signing MCP verified them.
  • GitHub Actions OpenAPI and Node tests passed at commit e966f6692965917d8907bf7cb071ec5ddc1c6fa8 after fixing two CI regressions: (a) syncing four generated artifacts from the exact composer run openapi CI diff, and (b) providing the missing envelope capability fixture in the new Vitest test.
  • GitHub Actions already passed PHP lint, PHP coding style, static analysis and OpenAPI contract tests at this commit. Remaining workflow jobs may still be in progress; do not treat them as passed until completed.
  • The dedicated count validator test and live Nextcloud multipart transport have not been independently rerun outside CI.
  • Official OpenAPI regeneration and generated TypeScript Axios upload transport are not verified. Upstream Create Signature into flow to create account #401 remains open and still has the documented files[] multiplicity limitation. Do not mark Document multipart uploads in the OpenAPI contract #9435 complete on this basis.

Before marking ready for review

  • Run composer test:unit -- --filter FileControllerUploadCountTest
  • Run npx vitest run src/tests/components/Request/RequestPicker.spec.ts src/tests/components/RightSidebar/EnvelopeFilesList.spec.ts
  • Run npm run ts:check, npm run lint, vendor/bin/phpunit -c tests/php/openapi/phpunit.xml
  • Verify positive and negative multipart requests against an isolated real LibreSign instance (PDF single, 2 PDFs, truncated PHP upload, unauthorized actor), then run the extractor Create Signature into flow to create account #401 branch and SDK probe separately.

Closes no issue: #9435 remains blocked on upstream multipart extraction/SDK serialization and runtime evidence.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Code Metrics Report

Note: Metrics describe the revision analyzed by the successful PHPUnit run. Newer commits with pending, canceled or failed checks may not yet be represented in this report.

main (e961fd1) #9452 (9690201) +/-
Coverage 76.1% 76.2% +0.0%
Test Execution Time 3m41s 2m56s -45s
Details
  |                     | main (e961fd1) | #9452 (9690201) |  +/-  |
  |---------------------|----------------|-----------------|-------|
+ | Coverage            |          76.1% |           76.2% | +0.0% |
  |   Files             |            500 |             500 |     0 |
  |   Lines             |          28578 |           28589 |   +11 |
+ |   Covered           |          21776 |           21785 |    +9 |
+ | Test Execution Time |          3m41s |           2m56s |  -45s |

Code coverage of files in pull request scope (25.0% → 26.9%, patch 84.6%)

Files Coverage +/- Patch Coverage Status
lib/Controller/FileController.php 26.9% +1.8% 84.6% modified

Reported by octocov

@vitormattos

Copy link
Copy Markdown
Member Author

/backport to stable35

@backportbot-libresign backportbot-libresign Bot added the backport-request Request to backport a change to supported stable branches label Nov 13, 2026
@vitormattos

Copy link
Copy Markdown
Member Author

/backport to stable34

@vitormattos

Copy link
Copy Markdown
Member Author

/backport to stable33

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant