Skip to content

VerifyProperties fails to detect getPagesLibraryExpression as dirty, leading to potential errors further down the road #961

@heinrich-ulbricht

Description

@heinrich-ulbricht

Category

  • Bug

Describe the bug

I described the bug over here because I initially thought this is an error in the provisioning engine -> pnp/pnpframework#716

Steps to reproduce

Not sure ^^. But see pnp/pnpframework#716 for more text.

Expected behavior

I expect VerifyProperties to detect when RootFolder.ServerRelativeUrl is not loaded yet.

Environment details (development & target environment)

See pnp/pnpframework#716

Additional context

I put lots of Console.WriteLines in the code and this is what I found:

This method:

private static List<Expression<Func<TModel, object>>> VerifyProperties(IDataModel<TModel> model, Expression<Func<TModel, object>>[] expressions, ref bool dirty)

...fails to handle this expression properly:

private static readonly Expression<Func<IList, object>>[] getPagesLibraryExpression = new Expression<Func<IList, object>>[] {p => p.Title, p => p.TemplateType, p => p.EnableFolderCreation,
p => p.EnableMinorVersions, p => p.EnableModeration, p => p.EnableVersioning, p => p.ForceCheckout, p => p.RootFolder.QueryProperties(p => p.Properties, p => p.ServerRelativeUrl), p => p.ListItemEntityTypeFullName, p => p.Fields };

Specifically it fails to dive into the properties defined in p.RootFolder.QueryProperties here:

var collection = model.GetPublicInstancePropertyValue(fieldToLoad);
if (collection is IRequestableCollection)

collection here is of type PnP.Core.Model.SharePoint.Folder (fieldToLoad == "RootFolder"), not IRequestableCollection. This immediately leaves the function leaving the dirty flag unchecked. This leads to errors in other code that now assumes that e.g. the RootFolder.ServerRelativeUrl property is loaded. Because it might not be. And in my case sometimes wasn't.

I have no clue how to fix this ^^

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions