OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.39k stars 2.39k forks source link

Orchard quietly fails saving when index is faulty #11143

Open brunoAltinet opened 2 years ago

brunoAltinet commented 2 years ago

Describe the bug

When using ReduceIndex, when Map part returns null, yessql throws nullref exception and Orchard queitly fails saving. It happened even before with faulty Map indexes (nothing would get saved if map index threw exception) so that's why i'm reporting it here, there should be some notification that the save failed.

To Reproduce

Add a ReduceIndex which returns null for Map. Try saving anything in admin, won't work

   public class PaymentByDayIndexProvider : IndexProvider<ContentItem>
    {
        public override void Describe(DescribeContext<ContentItem> context)
        {
            context.For<PaymentByDayIndex>()
                .Map(contentItem =>
                {;
                    return null;
                }).Group(x => x.Date)
                .Reduce(g => ...).
                Delete((ndx, map) => ...});
        }
    }

This should be a supported scenario in my opinion since returning null is standard practice in MapIndex.

Expected behavior

Orchard manages to save or notifies of failuer, or throws exception

Screenshots

None

sebastienros commented 2 years ago

Sounds like a bug in yessql, it should check for null values returned by Map().

sebastienros commented 2 years ago

Can you file it in yessql if you agree with me?

brunoAltinet commented 2 years ago

YesSql thrwos exception when called directly, orchard "swallows" the exception when doing work through admin interface

brunoAltinet commented 2 years ago

But yea, there's also that part where null throws exception, that's another part of it:)

Piedone commented 4 months ago

Is this still a YesSql issue @sebastienros?