Sitecore Command Line Interface also called Sitecore CLI is a good tool to serialize and deploy your content changes like templates, renderings, standard values etc. However being a new tool it has its limitations. I have shared couple of blog posts on how to ensure that there are no duplicate items in Sitecore before you run the serialization pull or push commands. If you still continue to get this error it means something else is wrong as well.

With growing data in Sitecore, serialization in one go becomes a challenge, we were using Sitecore CLI 5.1.25 but getting this error only in Production (not a good environment to get the errors). Since rest of the setup was exactly the same it was not difficult to realize its mainly due to excessive amount of Data in Production.
[GraphQLHttpException] Unexpected HttpResponseMessage with code: BadGateway
at GraphQL.Client.Http.Internal.GraphQLHttpHandler.ReadHttpResponseMessageAsync(HttpResponseMessage httpResponseMessage)
at GraphQL.Client.Http.Internal.GraphQLHttpHandler.PostAsync(GraphQLRequest request, CancellationToken cancellationToken)
at Sitecore.DevEx.Core.Client.GraphQl.SitecoreApiClient.<>c__DisplayClass11_0.<<RunQuery>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Sitecore.DevEx.Configuration.Authentication.OidcAuthenticationProvider.MakeAuthenticatedRequestInternal(HttpClient client, Func`2 requestAction) in C:\BA\ca7111d945a16af4\src\Sitecore.DevEx.Configuration\Authentication\OidcAuthenticationProvider.cs:line 87
at Sitecore.DevEx.Configuration.Authentication.OidcAuthenticationProvider.MakeAuthenticatedRequest(HttpClient client, Func`2 requestAction) in C:\BA\ca7111d945a16af4\src\Sitecore.DevEx.Configuration\Authentication\OidcAuthenticationProvider.cs:line 76
at Sitecore.DevEx.Configuration.Models.EnvironmentConfiguration.MakeAuthenticatedRequest(HttpClient client, Func`2 requestAction) in C:\BA\ca7111d945a16af4\src\Sitecore.DevEx.Configuration\Models\EnvironmentConfiguration.cs:line 275
at Sitecore.DevEx.Core.Client.GraphQl.SitecoreApiClient.RunQuery(String servicePath, GraphQLRequest request, Boolean assertNoErrors, CancellationToken cancellationToken)
at Sitecore.DevEx.Serialization.Client.Datasources.Sc.Query.SitecoreTreeDataStore.ExecuteSingleBatchQuery[T](String batchQueryFragment, TreeScope scope, ItemSpec[] specs, CancellationToken cancellationToken)
at Sitecore.DevEx.Serialization.Client.Datasources.Sc.Query.SitecoreTreeDataStore.<>c__DisplayClass21_0`1.<<CreateParallelQuery>b__0>d.MoveNext()
I raised a support ticket and Sitecore support was quick to jump on and suggested to upgrade Sitecore CLI and Sitecore Management Services
Solution to fix this error
There is a new feature called the “Progressive metadata pull” in CLI 6.0.23, which should help to solve this problem as this way the metadata resolution will run in a batched manner instead of running in one go which should mitigate the performance issue.
Please follow the instructions below to apply the latest changes:
- Install Sitecore Management Services 5.2.123 or a later version: Download Sitecore CLI
- Upgrade Sitecore CLI to the latest version as described here: Upgrade the Sitecore CLI
- The latest Sitecore CLI version uses the .NET 6 runtime.
- To upgrade all modules locally, please run the following CLI command (elevated permissions are necessary):
dotnet tool update sitecore.cli
- To ensure the changes are applied, please execute the command:
dotnet sitecore plugin list
. The installed module version should be 6.0.23.
- Enable the new feature by adding the “progressiveMetadataPull” serialization property in the sitecore.json file:
{
"$schema": "./.sitecore/schemas/RootConfigurationFile.schema.json",
"modules": ["./*.module.json"],
"plugins": ["[email protected]"],
"serialization": {
"defaultMaxRelativeItemPathLength": 100,
"defaultModuleRelativeSerializationPath": "serialization",
"removeOrphansForRoles": true,
"removeOrphansForUsers": true,
"continueOnItemFailure": false,
"excludedFields": [],
"progressiveMetadataPull": true
},
"settings": {
"telemetryEnabled": true,
"cacheAuthenticationToken": true,
"versionComparisonEnabled": true,
"apiClientTimeoutInMinutes": 5
}
}
I followed these steps and BOOM the issue was resolved, there were couple of bumps along the way as usual as we are running Sitecore in Docker Containers locally as well as in Azure. I will elaborate more on those in my next blog post, please stay tuned.