Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling feature breaks Admin Menu #16405

Closed
MikeAlhayek opened this issue Jul 5, 2024 · 14 comments · Fixed by #16415
Closed

Enabling feature breaks Admin Menu #16405

MikeAlhayek opened this issue Jul 5, 2024 · 14 comments · Fixed by #16415
Labels
Milestone

Comments

@MikeAlhayek
Copy link
Member

MikeAlhayek commented Jul 5, 2024

Describe the bug

Enabled any feature seems to break the Admin Menu. I think this is SJT related issue

Orchard Core version

Add the version of the Orchard Core NuGet packages you use, or the commit hash if you can reproduce this with the source code.

To Reproduce

Steps to reproduce the behavior:

  1. Enable Redis cache feature
  2. Enabled Admin Menu and add 2 content type menu nodes
  3. Go to Configurations >> Recipes >> Run the Blog - Lucene Search recipe
  4. you'll notice the menu items disappeared from the left side.
  5. Also, if you go to Configuration >> Admin Menus >> Edit nodes

Can't show the item of type: OrchardCore.AdminMenu.Models.AdminNode. Maybe a required module has been disabled?

image

Expected behavior

A clear and concise description of what you expected to happen.

Logs and screenshots

OrchardCore.AdminMenu.Services.AdminMenuNavigationProvidersCoordinator|ERROR|No Builder registered for admin node of type 'AdminNode'

_logger.LogError("No Builder registered for admin node of type '{TreeNodeName}'", node.GetType().Name);

@MikeAlhayek MikeAlhayek added this to the 2.0 milestone Jul 5, 2024
Copy link
Contributor

github-actions bot commented Jul 5, 2024

We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues).

This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here.

@MikeAlhayek
Copy link
Member Author

MikeAlhayek commented Jul 5, 2024

@Piedone can you recreate this issue is your environment?

@gvkries could this be related to ITypeFeatureProvider changes? Maybe something about the order of enabling services

@Piedone
Copy link
Member

Piedone commented Jul 5, 2024

With 52dca20 I can't see this, some repro steps are missing I assume. Starting with the Blog recipe, it works:

image

BTW you have to show what the Simulator menu does :).

@MikeAlhayek
Copy link
Member Author

@Piedone I am afraid that is confidential demo for the 2024 conference :)

By the way, I get the same issue when also running a recipe.

@Piedone
Copy link
Member

Piedone commented Jul 7, 2024

What exactly are you doing? I have no repro with 80ef1c7:

2024-07-07_21h28_53.mp4

This starts after an SQLite Blog setup.

@gvkries
Copy link
Contributor

gvkries commented Jul 8, 2024

I also cannot reproduce this...

@MikeAlhayek
Copy link
Member Author

MikeAlhayek commented Jul 9, 2024

I am looking more into this. This seems to only happens when REDIS cache is enabled.

Try starting your web project with the following and configure REDIS instance.

ocBuilder.AddSetupFeatures("OrchardCore.Redis", "OrchardCore.Redis.Lock")
         .AddGlobalFeatures("OrchardCore.Redis",
         "OrchardCore.Redis.Cache",
         "OrchardCore.Redis.DataProtection",
         "OrchardCore.Redis.Lock");

run a recipe.

@MikeAlhayek
Copy link
Member Author

MikeAlhayek commented Jul 9, 2024

This may not be related but I am seeing this in the logs

ERROR|Failed to read the 'ContentDefinitionRecord' from the distributed cache System.Text.Json.JsonException: '0x1F' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
 ---> System.Text.Json.JsonReaderException: '0x1F' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.
   at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
   at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)
   at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first)
   at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
   at System.Text.Json.Utf8JsonReader.Read()
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   --- End of inner exception stack trace ---
   at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo`1 jsonTypeInfo, Nullable`1 actualByteCount)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo`1 jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
   at System.Text.Json.JConvert.DeserializeObject[TValue](String json, JsonSerializerOptions options)
   at OrchardCore.Documents.DefaultDocumentSerializer.DeserializeAsync[TDocument](Byte[] data)
   at OrchardCore.Documents.DocumentManager`1.GetFromDistributedCacheAsync()
   at OrchardCore.Documents.DocumentManager`1.GetInternalAsync(Boolean failover)
   at OrchardCore.Documents.DocumentManager`1.GetOrCreateImmutableAsync(Func`1 factoryAsync)    at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo`1 jsonTypeInfo, Nullable`1 actualByteCount)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo`1 jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
   at System.Text.Json.JConvert.DeserializeObject[TValue](String json, JsonSerializerOptions options)
   at OrchardCore.Documents.DefaultDocumentSerializer.DeserializeAsync[TDocument](Byte[] data)
   at OrchardCore.Documents.DocumentManager`1.GetFromDistributedCacheAsync()
   at OrchardCore.Documents.DocumentManager`1.GetInternalAsync(Boolean failover)
   at OrchardCore.Documents.DocumentManager`1.GetOrCreateImmutableAsync(Func`1 factoryAsync)

@Piedone
Copy link
Member

Piedone commented Jul 9, 2024

I see, then maybe this is again an STJ issue. I won't be able to try it anytime soon, but I guess this being related to Redis was the missing piece.

@MikeAlhayek
Copy link
Member Author

I figured out the issue with ERROR|Failed to read the 'ContentDefinitionRecord' from the distributed cache System.Text.Json.JsonException: '0x1F' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.

I'll submit a PR to fix that issue. It could also fix this issue as well.

@MikeAlhayek
Copy link
Member Author

MikeAlhayek commented Jul 9, 2024

PR #16414 Fixes the Failed to read the 'ContentDefinitionRecord' from the distributed cache System.Text.Json.JsonException: '0x1F' error. But does not fix the AdminMenu issue.

I updated the Repo step in case someone wants to give it a shot.

@MikeAlhayek
Copy link
Member Author

@sebastienros this is a SJT problem. I think it is being deserialized incorrectly. Take the below JSON for example, we deserialize it to AdminMenuList

Each entry in the MenuItems gets deserialized to AdminNode instead of it's actual type. For example:

{
    "$type":"OrchardCore.AdminMenu.AdminNodes.LinkAdminNode, OrchardCore.AdminMenu",
    "LinkText":"Blog",
    "LinkUrl":"Admin/Contents/ContentItems/4aa81f8cgtbgdxrs6v6vww1kne/Display",
    ...
},

is deserialized into AdminNode instead of LinkAdminNode. LinkAdminNode is registered using the AddAdminNode extensio.

services.AddAdminNode<LinkAdminNode, LinkAdminNodeNavigationBuilder, LinkAdminNodeDriver>();

which is registered usinf AddJsonDerivedTypeInfo here

services.AddJsonDerivedTypeInfo<T, AdminNode>();

{
    "AdminMenu":[
        {
            "Id":"baef6f85ad13481681cde70ada401333",
            "Name":"Admin menus",
            "Enabled":true,
            "MenuItems":[
                {
                    "$type":"OrchardCore.AdminMenu.AdminNodes.LinkAdminNode, OrchardCore.AdminMenu",
                    "LinkText":"Blog",
                    "LinkUrl":"Admin/Contents/ContentItems/4aa81f8cgtbgdxrs6v6vww1kne/Display",
                    "IconClass":"fas fa-rss",
                    "PermissionNames":[
                        
                    ],
                    "UniqueId":"7b293d57056a4eebb3713f07f12c65d8",
                    "Enabled":true,
                    "Priority":0,
                    "LinkToFirstChild":true,
                    "LocalNav":false,
                    "Items":[
                        
                    ],
                    "Classes":[
                        
                    ]
                },
                {
                    "$type":"OrchardCore.AdminMenu.AdminNodes.LinkAdminNode, OrchardCore.AdminMenu",
                    "LinkText":"Main Menu",
                    "LinkUrl":"Admin/Contents/ContentItems/45bm7w3my93kb5j588w2brsqwt/Edit",
                    "IconClass":"fas fa-sitemap",
                    "PermissionNames":[
                        
                    ],
                    "UniqueId":"5118cecfde834dacb26ac08980f1b5a7",
                    "Enabled":true,
                    "Priority":0,
                    "LinkToFirstChild":true,
                    "LocalNav":false,
                    "Items":[
                        
                    ],
                    "Classes":[
                        
                    ]
                },
                {
                    "$type":"OrchardCore.AdminMenu.AdminNodes.PlaceholderAdminNode, OrchardCore.AdminMenu",
                    "LinkText":"Content",
                    "PermissionNames":[
                        
                    ],
                    "UniqueId":"3e590d44f8704e4588e272dd966ce291",
                    "Enabled":true,
                    "Priority":0,
                    "LinkToFirstChild":true,
                    "LocalNav":false,
                    "Items":[
                        {
                            "$type":"OrchardCore.AdminMenu.AdminNodes.LinkAdminNode, OrchardCore.AdminMenu",
                            "LinkText":"Content Items",
                            "LinkUrl":"Admin/Contents/ContentItems/",
                            "PermissionNames":[
                                
                            ],
                            "UniqueId":"7b293d57056a4eebb3713f07f12c65d9",
                            "Enabled":true,
                            "Position":"0",
                            "Priority":0,
                            "LinkToFirstChild":true,
                            "LocalNav":false,
                            "Items":[
                                
                            ],
                            "Classes":[
                                
                            ]
                        },
                        {
                            "$type":"OrchardCore.AdminMenu.AdminNodes.PlaceholderAdminNode, OrchardCore.AdminMenu",
                            "LinkText":"Content Types",
                            "PermissionNames":[
                                
                            ],
                            "UniqueId":"2f1fc33133334a1abf7d1a0516ee8b4e",
                            "Enabled":true,
                            "Position":"1",
                            "Priority":50,
                            "LinkToFirstChild":true,
                            "LocalNav":false,
                            "Items":[
                                {
                                    "$type":"OrchardCore.Contents.AdminNodes.ContentTypesAdminNode, OrchardCore.Contents",
                                    "ShowAll":true,
                                    "ContentTypes":[
                                        
                                    ],
                                    "UniqueId":"ee18224e1b814c638b0732678b74cfd9",
                                    "Enabled":true,
                                    "Priority":0,
                                    "LinkToFirstChild":true,
                                    "LocalNav":false,
                                    "Items":[
                                        
                                    ],
                                    "Classes":[
                                        
                                    ]
                                }
                            ],
                            "Classes":[
                                
                            ]
                        }
                    ],
                    "Classes":[
                        
                    ]
                }
            ]
        }
    ],
    "Identifier":"40b6pzshwprbc6xa004p3hezxn"
}

@MikeAlhayek
Copy link
Member Author

PR #16415 seems to have fixed this issue!

@Piedone
Copy link
Member

Piedone commented Jul 11, 2024

Combo breaker :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants