{"record":{"id":"eb057e30dcf8c29b","repo":"OrchardCMS/OrchardCore","slug":"invalid-dependency-position-of-type-dependent-type-for","errorCode":null,"errorMessage":"Invalid dependency position of type '{dependent.Type}' for resource '{dependent.Name}' positioned at '{dependent.Position}' depending on '{Name}' positioned at '{Position}'","messagePattern":"Invalid dependency position of type '(.+?)' for resource '(.+?)' positioned at '(.+?)' depending on '(.+?)' positioned at '(.+?)'","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.ResourceManagement.Abstractions/RequireSettings.cs","lineNumber":227,"sourceCode":"            return other._attributes == null ? null : new Dictionary<string, string>(other._attributes);\n        }\n        if (other._attributes == null)\n        {\n            return new Dictionary<string, string>(_attributes);\n        }\n        var mergedAttributes = new Dictionary<string, string>(_attributes);\n        foreach (var pair in other._attributes)\n        {\n            mergedAttributes[pair.Key] = pair.Value;\n        }\n        return mergedAttributes;\n    }\n\n    public RequireSettings UpdatePositionFromDependent(RequireSettings dependent)\n    {\n        if (dependent.Position == ResourcePosition.First && Position == ResourcePosition.Last)\n        {\n            throw new InvalidOperationException($\"Invalid dependency position of type '{dependent.Type}' for resource '{dependent.Name}' positioned at '{dependent.Position}' depending on '{Name}' positioned at '{Position}'\");\n        }\n\n        // If a 'First' resource depends on a 'ByDependency' resource, position the dependency 'First'.\n        if (dependent.Position == ResourcePosition.First && Position == ResourcePosition.ByDependency)\n        {\n            Position = ResourcePosition.First;\n        }\n\n        return this;\n    }\n\n    public RequireSettings UpdatePositionFromDependency(RequireSettings dependency)\n    {\n        // If a 'ByDependency' resource depends on a 'Last' resource, position the dependent 'Last'.\n        if (Position == ResourcePosition.ByDependency && dependency.Position == ResourcePosition.Last)\n        {\n            Position = ResourcePosition.Last;\n        }","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.ResourceManagement.Abstractions/RequireSettings.cs#L209-L245","documentation":"RequireSettings.UpdatePositionFromDependent throws this InvalidOperationException when dependency ordering is contradictory: a resource required 'First' is positioned 'Last' while a resource that depends on it is positioned 'First' (Last cannot be reordered to satisfy a First-dependent). The dependency graph cannot be laid out in document order.","triggerScenarios":"Two resources where the dependent is required with ResourcePosition.First and the dependency is required with ResourcePosition.Last, via BuildPosition/CombinePosition during RequireSettings combination or dependency expansion.","commonSituations":"A theme requires a script 'at Foot/Last' while a module requires the same script 'at Head/First' and declares a dependency on it; conflicting positioning directives from two modules or a theme overriding module ordering for the same shared resource.","solutions":["Align the positions: require the dependency at First (or ByDependency) so a First-dependent can be satisfied.","Remove the explicit Last/First positioning on one of the two conflicting resources and let default ByDependency ordering apply.","Resolve which module/theme imposes the ordering and change it in that module's ResourceManifest or the RequireSettings call.","If you own both calls, drop the dependency or the positional constraint so ordering is unambiguous."],"exampleFix":"// before\nsettings.BuildPosition(ResourcePosition.Last); // dependency required Last\nrequired.BuildPosition(ResourcePosition.First); // dependent required First -> conflict\n// after\nsettings.BuildPosition(ResourcePosition.ByDependency); // allow ordering by dependency","handlingStrategy":"validation","validationCode":"if (dependent.Position == ResourcePosition.First && dependency.Position == ResourcePosition.Last)\n    throw new InvalidOperationException(\"Cannot require a First-positioned resource that depends on a Last-positioned resource.\");","typeGuard":null,"tryCatchPattern":"try\n{\n    resourceManager.GetRequiredResources(resourceType);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Invalid dependency position\"))\n{\n    logger.LogWarning(ex, \"Conflicting resource positioning; using default ordering.\");\n}","preventionTips":["Only use First/Last positioning on leaf resources, not shared dependencies.","Let dependencies order themselves via ByDependency (the default).","Audit themes and modules that both position the same shared resource (e.g. jQuery).","Document positioning intent in one place (the manifest) rather than scattered Require calls."],"tags":["resources","orchardcore","ordering","dependency-graph"],"backgroundTag":"conflicting-config-options","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}