{"record":{"id":"8631ef3f5cc4163d","repo":"OpenRA/OpenRA","slug":"actorinfo-name-failed-to-initialize-because-o","errorCode":null,"errorMessage":"ActorInfo(\"{Name}\") failed to initialize because of the following:\nMissing:\n{missing}\nUnresolved:\n{unresolved}","messagePattern":"ActorInfo\\(\"(.+?)\"\\) failed to initialize because of the following:\nMissing:\n(.+?)\nUnresolved:\n(.+?)","errorType":"exception","errorClass":"YamlException","httpStatus":null,"severity":"error","filePath":"OpenRA.Game/GameRules/ActorInfo.cs","lineNumber":162,"sourceCode":"\t\t\tif (unresolved.Count != 0)\n\t\t\t{\n\t\t\t\tvar exceptionString = \"ActorInfo(\\\"\" + Name + \"\\\") failed to initialize because of the following:\\n\";\n\t\t\t\tvar missing = unresolved.SelectMany(u => u.Dependencies.Where(d => !source.Any(s => AreResolvable(d, s.Type)))).Distinct();\n\n\t\t\t\texceptionString += \"Missing:\\n\";\n\t\t\t\tforeach (var m in missing)\n\t\t\t\t\texceptionString += m + \" \\n\";\n\n\t\t\t\texceptionString += \"Unresolved:\\n\";\n\t\t\t\tforeach (var u in unresolved)\n\t\t\t\t{\n\t\t\t\t\tvar deps = u.Dependencies.Where(d => !resolved.Exists(r => r.Type == d));\n\t\t\t\t\tvar optDeps = u.OptionalDependencies.Where(d => !resolved.Exists(r => r.Type == d));\n\t\t\t\t\tvar allDeps = string.Join(\", \", deps.Select(o => o.ToString()).Concat(optDeps.Select(o => $\"[{o}]\")));\n\t\t\t\t\texceptionString += $\"{u.Type}: {{ {allDeps} }}\\n\";\n\t\t\t\t}\n\n\t\t\t\tthrow new YamlException(exceptionString);\n\t\t\t}\n\n\t\t\tconstructOrderCache = resolved.Select(r => r.Trait).ToArray();\n\t\t\treturn constructOrderCache;\n\t\t}\n\n\t\tpublic static IEnumerable<Type> PrerequisitesOf(TraitInfo info)\n\t\t{\n\t\t\treturn info\n\t\t\t\t.GetType()\n\t\t\t\t.GetInterfaces()\n\t\t\t\t.Where(t => t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Requires<>))\n\t\t\t\t.Select(t => t.GetGenericArguments()[0]);\n\t\t}\n\n\t\tpublic static IEnumerable<Type> OptionalPrerequisitesOf(TraitInfo info)\n\t\t{\n\t\t\treturn info","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/OpenRA/OpenRA/blob/a520984d91eda9de48a62b1d15c1e3bad0d4fb1a/OpenRA.Game/GameRules/ActorInfo.cs#L144-L180","documentation":"Thrown by TraitsInConstructOrder when, after topological resolution, some traits remain unresolved because their Requires<> dependencies cannot be satisfied by any other trait on the actor. The message lists missing (unsatisfiable) dependency types and unresolved traits with their dangling dependencies.","triggerScenarios":"Calling TraitsInConstructOrder on an ActorInfo where a trait declares a Requires<T> dependency for which no matching T trait is present (or a dependency cycle blocks resolution), leaving unresolved.Count > 0.","commonSituations":"Adding a trait that requires another (e.g. a Render trait requiring Health) without adding the dependency; renaming/removing a dependency trait; circular Requires<> dependencies; conditional traits that drop a required dependency.","solutions":["Add the missing dependency trait(s) named in the 'Missing' section of the message.","Break any circular Requires<> dependencies flagged in the 'Unresolved' section.","Reorder or remove traits that reference deleted dependency types.","Use the linter to detect unmet trait prerequisites across all actors."],"exampleFix":"# before - Render requires Health but Health missing\nActor:\n    RenderSprites:\n# after\nActor:\n    Health:\n        HP: 100\n    RenderSprites:","handlingStrategy":"validation","validationCode":"// Pre-check trait prerequisites before construct order resolution\nforeach (var trait in traits)\nforeach (var req in ActorInfo.PrerequisitesOf(trait))\n    if (!traits.Any(t => req.IsAssignableFrom(t.GetType())))\n        // report the unmet prerequisite early","typeGuard":null,"tryCatchPattern":"try { actorInfo.TraitsInConstructOrder(); }\ncatch (YamlException ex) when (ex.Message.Contains(\"failed to initialize\"))\n{ /* parse Missing/Unresolved lists and add dependency traits */ }","preventionTips":["Always add the dependency trait when adding a Requires<> trait.","Avoid circular Requires<> dependencies.","Lint actors to detect unmet trait prerequisites."],"tags":["trait","dependencies","rules","openra"],"backgroundTag":null,"analyzedSha":"a520984d91eda9de48a62b1d15c1e3bad0d4fb1a","analyzedAt":"2026-08-13T15:30:14.787Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}