Skip to content

Package import errors if dependent on composition in a dependant package #11987

Open
@tconnellredmane

Description

@tconnellredmane

Which exact Umbraco version are you using? For example: 9.0.1 - don't just write v9

9.3.0-rc1

Bug summary

Working with a complex site that uses packages to modularize code and promote reuse (good things!). I've run into an issue where I get an error "Missing dependency. Error in type Node`2, with key [composition name]" when it tries to load the package that consumes the dependency. This happens whether the dependent package already exists in the project or is loaded from the consuming package.

As a result of the error, neither package's elements are installed

Specifics

This appears to be an issue in the graph sorting XML elements in dependency order at Umbraco.Cms.Infrastructure.Packaging.PackageDataInstallation, line 517. The TopoGraph used to sort dependencies throws the "Missing Dependency" error because it cannot find the composition from the dependency. Its scope is limited to the current XMLDocument contents. The composition dependency is not resolved until the call to Create/UpdateContentTypeFromXml on line 528 (which resolves the composition on line 801).

This may be the cause or similar to Issue #8128 and would also handle the request made in #11763

It seems like there is a simple fix for this (PR forthcoming): setting throwOnMissing = true in the graph.GetSortedListCall on line 517
List documentTypes = isSingleDocTypeImport
? unsortedDocumentTypes.ToList()
: graph.GetSortedItems(throwOnMissing:false).Select(x => x.Item).ToList();

Steps to reproduce

Set up a package that includes a composition definition. Pack it via NuGet and host it locally
Setup a package project with a document type that implements the composition defined in step 1
Set up a test project for the package defined n step 2
Run the test project. You will see the missing dependency error in the log/console.

Expected result / actual result

There should be no error and all elements from both packages should be visible in the Document Types list.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions