Problem with building the asset bundle with scene

After updating my project to 2022.2.1f1 I found a very problematic bug that won’t let me to build asset bundles that containing scene. I got a message after 50 seconds:

Object reference not set to an instance of an object```

The problem occurs in my code here:

```csharp
private ReturnCode BuildBundles(IBundleBuildContent buildContent, IBundleBuildParameters buildParameters)
{
   var taskList = Bundles.Tasks.Build.CalculateAndBuildBundles(); //<----------- here
   var code = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out var results, taskList);

   return returnCode;
}
public static IList<IBuildTask> CalculateAndBuildBundles()
{
   var buildTasks = CalculateCommonBundles(); //<----------- here

   // Dependency
   buildTasks.Add(new StripUnusedSpriteSources());
   buildTasks.Add(new PostDependencyCallback());

   // Packing
   buildTasks.Add(new GenerateBundlePacking());
   buildTasks.Add(new GenerateBundleCommands());
   buildTasks.Add(new GenerateSubAssetPathMaps());
   buildTasks.Add(new GenerateBundleMaps());
   buildTasks.Add(new PostPackingCallback());

   // Writing
   buildTasks.Add(new WriteSerializedFiles());
   buildTasks.Add(new ArchiveAndCompressBundles());

   buildTasks.Add(new CalculateDiffSignatures());
   buildTasks.Add(new WriteResimoManifest());
   buildTasks.Add(new PostWritingCallback());
   return buildTasks;
}
public static IList<IBuildTask> CalculateCommonBundles()
{
   var buildTasks = new List<IBuildTask>();

   // Setup
   buildTasks.Add(new SwitchToBuildPlatform());
   buildTasks.Add(new RebuildSpriteAtlasCache());

   buildTasks.Add(new BuildPlayerScripts());
   buildTasks.Add(new PostScriptsCallback());

   //Remove duplicated textures
   buildTasks.Add(new CalculateScenesDuplicatedDependencies());
   buildTasks.Add(new StripTextures());
   buildTasks.Add(new RefreshAssetDatabase());

   buildTasks.Add(new CalculateSceneDependencyData()); //<----------- here
   buildTasks.Add(new CalculateAssetDependencyData());

   return buildTasks;
}

When I test remove calling the CalculateSceneDependencyData(), I got the exception in ContentPipeline.BuildAssetBundles:

The given key '94658ac7db67db047947acd7a55d4bac' was not present in the dictionary.```

I tried another versions of unity like **2022.2.3f1**, **2022.2.2f1**, **2022.2.0b16**, **2022.2.0b10** and even **2023.1.0a18** but the problem also exists. The last working version is **2022.1.24f1**.

I removed any other asset bundles and left only this one with scene. I made sure that no dependencies are in several bundles. I also tried to build empty scene. Nothing helped. Only if I back to previous version (2022.1.24f1) the problem will disappear...

Has anyone encountered this problem?

For everyone who also have this problem. The bug has been reported to unity team and has been successfully reproduced. The issue tracker can be found here: Unity Issue Tracker - Unable to build asset bundle when using CalculateSceneDependencyData() method