OrchardCore icon indicating copy to clipboard operation
OrchardCore copied to clipboard

Invalid serial number for shell descriptor

Open cbadger-montecitobank opened this issue 1 year ago • 3 comments

I get an "Invalid serial number for shell descriptor" error if I have a module with two data migrations, and each migration executes a recipe with a "Feature" step. Example from DataMigration class:

    public async Task<int> CreateAsync()
    {
        await _recipeMigrator.ExecuteAsync("0001_migration.json", this);

        return 1;
    }

    public async Task<int> UpdateFrom1Async()
    {
        await _recipeMigrator.ExecuteAsync("0002_migration.json", this);

        return 2;
    }

Both recipes ("0001_migration.json" and "0002_migration.json") contain a "Feature" step that is meant to ensure certain core features are activated. If both of these migrations run back-to-back, which would happen when activating the feature for the first time, I get this error when the second recipe runs:

2024-05-08 13:45:50.2348|||0HN3FJV95DQPC:00000001|OrchardCore.Data.Migration.DataMigrationManager|ERR|Error while running migration version 1 for 'My.Test.Modules.FeaturesModule'.
System.InvalidOperationException: Invalid serial number for shell descriptor
   at OrchardCore.Environment.Shell.Data.Descriptors.ShellDescriptorManager.UpdateShellDescriptorAsync(Int32 priorSerialNumber, IEnumerable`1 enabledFeatures)
   at OrchardCore.Environment.Shell.ShellDescriptorFeaturesManager.UpdateFeaturesAsync(ShellDescriptor shellDescriptor, IEnumerable`1 featuresToDisable, IEnumerable`1 featuresToEnable, Boolean force)
   at OrchardCore.Features.Recipes.Executors.FeatureStep.ExecuteAsync(RecipeExecutionContext context)
   at OrchardCore.Recipes.Services.RecipeExecutor.<>c__DisplayClass7_0.<<ExecuteStepAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
   at OrchardCore.Recipes.Services.RecipeExecutor.ExecuteStepAsync(RecipeExecutionContext recipeStep)
   at OrchardCore.Recipes.Services.RecipeExecutor.ExecuteAsync(String executionId, RecipeDescriptor recipeDescriptor, IDictionary`2 environment, CancellationToken cancellationToken)
   at OrchardCore.Recipes.Services.RecipeExecutor.ExecuteAsync(String executionId, RecipeDescriptor recipeDescriptor, IDictionary`2 environment, CancellationToken cancellationToken)
   at OrchardCore.Recipes.Services.RecipeExecutor.ExecuteAsync(String executionId, RecipeDescriptor recipeDescriptor, IDictionary`2 environment, CancellationToken cancellationToken)
   at OrchardCore.Recipes.Services.RecipeExecutor.ExecuteAsync(String executionId, RecipeDescriptor recipeDescriptor, IDictionary`2 environment, CancellationToken cancellationToken)
   at OrchardCore.Recipes.Services.RecipeMigrator.ExecuteAsync(String recipeFileName, IDataMigration migration)
   at Mbt.Phase7.Modules.FeaturesModule.Migrations.DataMigrations.UpdateFrom1Async() in C:\workspace\Mbt.Phase7\Modules\FeaturesModule\Migrations\DataMigrations.cs:line 24
   at OrchardCore.Data.Migration.DataMigrationManager.UpdateAsync(String featureId)`

Works fine if I just have the one recipe run.

I'm running on OC 1.8.2. Is there something I'm doing wrong here? Other than abandoning the use of the RecipeMigrator to activate features, is there a way to make this work?

Thank you.

UPDATE: As a work-around for this issue I declared all the features I want activated as dependencies of my module. Orchard activates them automatically, meaning I don't need a migration recipe step. Adding additional dependencies after the feature is activated also seems to work fine, as Orchard will pick up on those and activate them. This meets my need at present, but the original issue presented seems to stand.

cbadger-montecitobank avatar May 08 '24 21:05 cbadger-montecitobank

This looks like a bug indeed, so your workaround is what you need to do currently. Declaring dependencies in your module's manifest is recommended anyway if your module indeed depends on them.

Piedone avatar May 10 '24 12:05 Piedone

The same error for me on v2.0.2.

2024-10-13 14:21:12.8401|Default||0HN7B9S62296H:00000005|OrchardCore.Setup.Services.SetupService|ERR|An error occurred while initializing the datastore.
System.InvalidOperationException: Invalid serial number for shell descriptor
   at OrchardCore.Environment.Shell.Data.Descriptors.ShellDescriptorManager.UpdateShellDescriptorAsync(Int32 priorSerialNumber, IEnumerable`1 enabledFeatures)
   at OrchardCore.Setup.Services.SetupService.<>c__DisplayClass14_1.<<SetupInternalAsync>b__1>d.MoveNext()
2024-10-13 14:39:44.0474|Default||0HN7BA6RUM31P:00000005|OrchardCore.Setup.Services.SetupService|ERR|An error occurred while initializing the datastore.
System.InvalidOperationException: Invalid serial number for shell descriptor
   at OrchardCore.Environment.Shell.Data.Descriptors.ShellDescriptorManager.UpdateShellDescriptorAsync(Int32 priorSerialNumber, IEnumerable`1 enabledFeatures)
   at OrchardCore.Setup.Services.SetupService.<>c__DisplayClass14_1.<<SetupInternalAsync>b__1>d.MoveNext()

gaojianzhuang avatar Oct 13 '24 06:10 gaojianzhuang

The same error for me on v2.0.2.

2024-10-13 14:21:12.8401|Default||0HN7B9S62296H:00000005|OrchardCore.Setup.Services.SetupService|ERR|An error occurred while initializing the datastore.
System.InvalidOperationException: Invalid serial number for shell descriptor
   at OrchardCore.Environment.Shell.Data.Descriptors.ShellDescriptorManager.UpdateShellDescriptorAsync(Int32 priorSerialNumber, IEnumerable`1 enabledFeatures)
   at OrchardCore.Setup.Services.SetupService.<>c__DisplayClass14_1.<<SetupInternalAsync>b__1>d.MoveNext()
2024-10-13 14:39:44.0474|Default||0HN7BA6RUM31P:00000005|OrchardCore.Setup.Services.SetupService|ERR|An error occurred while initializing the datastore.
System.InvalidOperationException: Invalid serial number for shell descriptor
   at OrchardCore.Environment.Shell.Data.Descriptors.ShellDescriptorManager.UpdateShellDescriptorAsync(Int32 priorSerialNumber, IEnumerable`1 enabledFeatures)
   at OrchardCore.Setup.Services.SetupService.<>c__DisplayClass14_1.<<SetupInternalAsync>b__1>d.MoveNext()

I'm on 2.0.2 and I'm currently getting this error also

tcobbfis avatar Oct 16 '24 21:10 tcobbfis