{"record":{"id":"f49bb5e15b3e244d","repo":"Unity-Technologies/UnityCsReference","slug":"more-assemblies-in-the-list-than-delivered-only-f","errorCode":null,"errorMessage":"More Assemblies in the list than delivered. Only filtering, not adding extra assemblies","messagePattern":"More Assemblies in the list than delivered\\. Only filtering, not adding extra assemblies","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs","lineNumber":1416,"sourceCode":"        [RequiredByNativeCode]\n        internal static string[] FilterAssembliesIncludedInBuild(BuildOptions buildOptions, string[] assemblies)\n        {\n            if (processors.filterBuildAssembliesProcessor == null)\n            {\n                return assemblies;\n            }\n\n            string[] startAssemblies = assemblies;\n            string[] filteredAssemblies = assemblies;\n\n            foreach (var filteredAssembly in processors.filterBuildAssembliesProcessor)\n            {\n                using var _ = new ScopeTraceProfileBlock($\"{filteredAssembly.GetType().Name}.OnFilterAssemblies\");\n                int assemblyCount = filteredAssemblies.Length;\n                filteredAssemblies = filteredAssembly.OnFilterAssemblies(buildOptions, filteredAssemblies);\n                if (filteredAssemblies.Length > assemblyCount)\n                {\n                    throw new Exception(\"More Assemblies in the list than delivered. Only filtering, not adding extra assemblies\");\n                }\n            }\n\n            if (!Array.TrueForAll(filteredAssemblies, x => startAssemblies.Contains(x)))\n            {\n                throw new Exception(\"New Assembly names are in the list. Only filtering are allowed\");\n            }\n\n            return filteredAssemblies;\n        }\n\n        [RequiredByNativeCode]\n        internal static void CleanupBuildCallbacks()\n        {\n            processors.buildTargetProcessors = null;\n            processors.buildPlayerProcessors = null;\n            processors.buildPreprocessors = null;\n            processors.buildPostprocessors = null;","sourceCodeStart":1398,"sourceCodeEnd":1434,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs#L1398-L1434","documentation":"Thrown during the assembly-filtering phase of a build when an IFilterBuildAssemblies processor's OnFilterAssemblies returns an array longer than the one it received. The contract is strictly subtractive: processors may only remove assemblies, never add them. This guard catches processors that violate that invariant by returning more entries than they were given.","triggerScenarios":"An IFilterBuildAssemblies implementation whose OnFilterAssemblies returns an array with more elements than the input assemblies array — e.g., by concatenating additional assembly names or returning a superset.","commonSituations":"A custom build processor attempts to inject additional assemblies into the build via the filter hook instead of using the correct API, or a processor accidentally creates a new array that duplicates entries. Also occurs when a third-party plugin's IFilterBuildAssemblies implementation is buggy or incompatible with the Unity version.","solutions":["Ensure OnFilterAssemblies only ever returns a subset (or the same set) of the assemblies it receives — never a superset.","If you need to add assemblies, use a different mechanism such as IPreprocessBuildWithReport or asmdef references rather than the filter hook.","Audit any installed packages/plugins that implement IFilterBuildAssemblies and disable or fix the offending one."],"exampleFix":"// before\npublic string[] OnFilterAssemblies(BuildOptions buildOptions, string[] assemblies)\n{\n    var list = new List<string>(assemblies);\n    list.Add(\"MyExtraAssembly.dll\"); // WRONG — only filtering is allowed\n    return list.ToArray();\n}\n\n// after\npublic string[] OnFilterAssemblies(BuildOptions buildOptions, string[] assemblies)\n{\n    // Only remove assemblies, never add\n    return assemblies.Where(a => !a.Contains(\"Test\")).ToArray();\n}","handlingStrategy":"validation","validationCode":"// Inside IFilterBuildAssemblies.OnFilterAssemblies:\npublic string[] OnFilterAssemblies(BuildOptions buildOptions, string[] assemblies)\n{\n    int inputCount = assemblies.Length;\n    string[] filtered = DoMyFiltering(assemblies);\n    // Postcondition: result must not be larger than input\n    if (filtered.Length > inputCount)\n        throw new InvalidOperationException(\n            $\"OnFilterAssemblies returned {filtered.Length} entries but received {inputCount}. Only removal is allowed.\");\n    return filtered;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat OnFilterAssemblies as strictly subtractive: only remove, never add.","Add a postcondition assertion in your processor that the returned array length does not exceed the input.","Use a different extension point (asmdef, Link XML) if you need to add or redirect assemblies."],"tags":["unity","build-pipeline","assembly-filtering","build-processor","ifilterbuildassemblies"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}