Skip to content

fix: file upload content length - #301

Merged
armando-rodriguez-cko merged 4 commits into
masterfrom
bugfix/INT-1597-file-upload-content-length
Feb 20, 2026
Merged

fix: file upload content length#301
armando-rodriguez-cko merged 4 commits into
masterfrom
bugfix/INT-1597-file-upload-content-length

Conversation

@armando-rodriguez-cko

@armando-rodriguez-cko armando-rodriguez-cko commented Feb 18, 2026

Copy link
Copy Markdown
Contributor

This pull request improves the reliability and security of file uploads in the SDK, particularly ensuring that file uploads include the correct Content-Length header to meet API requirements. It also clarifies documentation and type annotations regarding file path handling, and adds robust automated tests to verify correct upload behavior.

File upload reliability and API compatibility:

  • Updated the file upload logic in ApiClient to use a Guzzle stream with an explicit size, ensuring that the Content-Length header is set for multipart uploads. This prevents failures with APIs that reject chunked uploads without a content length.
  • Added and updated tests (ApiClientTest, DisputesClientTest, and integration tests) to verify that file uploads send the correct Content-Length header and that its value matches the actual body size. [1] [2] [3]

Security and documentation improvements:

  • Enhanced documentation and type annotations in FileRequest.php, FilesClient.php, and the README to emphasize that file paths must be application-controlled and not taken directly from untrusted user input. [1] [2] [3]
  • Updated the README to announce version 4.0.0 and clarify default behaviors and migration notes.

Test and configuration updates:

  • Adjusted test setup to use the default platform type and ensured file upload requests in tests include the correct purpose and headers. [1] [2] [3]

- Set explicit stream size in ApiClient::submit() so Guzzle sends
  Content-Length instead of Transfer-Encoding: chunked (rejected by API)
- Add filename to multipart file part for proper Content-Disposition
- Add security note in FileRequest/uploadFile: path must be app-controlled
- Add ApiClientTest for Content-Length header and body size consistency
- Compatible with PHP 7.1–8.4 and PHPUnit 5.7 / 9
@armando-rodriguez-cko
armando-rodriguez-cko requested a review from a team February 18, 2026 10:26
@armando-rodriguez-cko armando-rodriguez-cko changed the title Bugfix/int 1597 file upload content length fix: file upload content length Feb 18, 2026
- Use PlatformType::$default (previous deprecated)
- Add uploadFileSendsContentLengthHeader() for INT-1597
- Set purpose in shouldUploadFile; add INT-1597 doc to integration test
@sonarqubecloud

Copy link
Copy Markdown

@armando-rodriguez-cko
armando-rodriguez-cko merged commit 81e5793 into master Feb 20, 2026
6 checks passed
@armando-rodriguez-cko
armando-rodriguez-cko deleted the bugfix/INT-1597-file-upload-content-length branch February 20, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants