Explanation of the error
Salesforce returns this error when the deployment package for a pull request (PR) validation is larger than the Metadata API accepts in a single request.
Salesforce returns the following error:
Maximum size of request reached. Maximum size of request is 52428800 bytes.
Gearset shows it on the validation page with this message:
"The deployment package exceeds Salesforce's upload limits. Validations may be successful if you:
Perform a series of smaller deployments to migrate all of your changes.
Use filters to remove some of the larger files from the deployment package."
The error comes from Salesforce's limits on deploying metadata through the Metadata API. According to Salesforce's reference on Metadata Limits, these are the limits:
The deployed .zip file can contain up to 10,000 files.
The deployed .zip file can be up to 39 MB compressed, or 600 MB uncompressed.
The Metadata API base64-encodes the compressed .zip file, and the encoded request can't exceed 50 MB. This 50 MB is the 52,428,800 bytes in the error message.
Base64 encoding makes the payload larger, so the compressed deployment package can't exceed approximately 39 MB before encoding.
The limit is on the size of the deployment package, not the number of components. A PR with only a few components can still hit this error if some of its files are large.
Note: Gearset doesn't split a PR validation into smaller packages automatically. To validate the changes successfully, reduce the size of the deployment package using one of the workarounds below.
Resolution
Before choosing a workaround, find out which files in the deployment package are the largest.
If you have committed changes to a feature branch from which a PR was opened in your Gearset Pipeline, open the PR's changed files in your Git provider and check their sizes. The largest files usually decide which workaround fits.
Workaround 1: Split the changes into smaller PRs
Divide the PR's changes into two or more smaller PRs.
Keep each PR's deployment package under 39 MB compressed. Spread the largest files across different PRs rather than keeping them together.
Validate and promote each PR in turn.
Workaround 2: Exclude the largest files using the CI job's metadata filter
Edit the metadata filter of the CI job that validates the PR, and exclude the metadata types that contain the largest files. For the steps, see Manage custom filters in CI jobs.
Run the validation again.
Restore the CI job's original metadata filter.
Promote the excluded files in a separate PR.
When you edit a saved custom filter for a CI job, the change applies to every CI job that uses that filter, not only the CI job validating the PR you're working on.
Remember that if any components in the PR reference the files you exclude from the CI job's metadata filter, the validation can fail with missing-dependency validation errors. In that case, promote the referenced files first, or use Workaround 1.
Further considerations
If neither workaround reduces the deployment package enough so that your deployment could pass the validation, you're welcome to reach out to Gearset Support via the in-app chat and we'll do our best to assist further.
For a similar size limit that applies when Gearset retrieves metadata during a comparison, see How does Gearset handle requests that exceed the download limit?
Disclaimer: This error is returned directly by Salesforce, rather than Gearset. Even so, we offer guidance based on our combined experience with the Metadata API. Where possible, we try to help guide you to fix or avoid this error. In the case that this isn't possible, we may need to direct you to Salesforce support for further clarification.

