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

Support for Placeholder Fields property to be an Array #8

Closed
1 task done
robearlam opened this issue Aug 15, 2024 · 2 comments · Fixed by #14
Closed
1 task done

Support for Placeholder Fields property to be an Array #8

robearlam opened this issue Aug 15, 2024 · 2 comments · Fixed by #14
Labels
bug Something isn't working

Comments

@robearlam
Copy link
Member

What happened?

The OOTB Navigation component in XM-Cloud uses a custom Content Resolver to adjust the returned JSON and make the route.placeholders.placeholder[0].fields property into an Array. This SDK is configured to only handle the field property as an Object.

Navigation Item RCR Field contents:
image

Target RCR type:
image

This causes the Sitecore.AspNetCore.SDK.LayoutService.Client.Serialization.Converter.FieldParser to throw a JsonException as its expecting and object and not an array:

image

Reproduction Steps

  1. Create a site in XM Cloud
  2. Point your ASP.NET Core Head application to the site
  3. Drag the Navigation component to the page

Actual Behavior

  • Fatal exception, the page can no longer be rendered so its not even possible to remove the component via Pages. You need to remove is by editing the Layout Data via the Content Editor.

Expected Behavior

  • Arrays of placeholder Fields should be supported.

Relevant log output

{
  "sitecore": {
    "context": {
      "pageEditing": false,
      "site": {
        "name": "aspnet-core-starter"
      },
      "pageState": "normal",
      "editMode": "chromes",
      "language": "en",
      "itemPath": "/"
    },
    "route": {
      "name": "Home",
      "displayName": "Home",
      "fields": {
        "Title": {
          "value": "aspnet-core-starter-123"
        },
        "Content": {
          "value": "<p>Page COntent COntent!</p>"
        },
        "NavigationClass": null,
        "NavigationFilter": [
          
        ],
        "NavigationTitle": {
          "value": "aspnet-core-starter"
        },
        "Page Design": null,
        "SxaTags": [
          
        ]
      },
      "databaseName": "master",
      "deviceId": "fe5d7fdf-89c0-4d99-9aa3-b5fbd009c9f3",
      "itemId": "27fa2701-5a1a-43b8-bb6b-c86baae7961d",
      "itemLanguage": "en",
      "itemVersion": 1,
      "layoutId": "96e5f4ba-a2cf-4a4c-a4e7-64da88226362",
      "templateId": "195a62a9-2c45-4f38-b9f7-6aff652bdadf",
      "templateName": "Page",
      "placeholders": {
        "headless-header": [
          {
            "uid": "e92cda14-efca-4abd-8e0f-cff8dfd74066",
            "componentName": "Navigation",
            "dataSource": "",
            "params": {
              "GridParameters": "col-12",
              "FieldNames": "Default",
              "LevelFrom": "{1BB88840-5FB3-4353-AD8D-81136F6FF75A}",
              "LevelTo": "{A59325BB-5A27-46F9-8110-9D499715F3BE}"
            },
            "fields": [
              {
                "Id": "b0dade99-22d2-4853-aa53-b4e1b2bdd680",
                "Styles": [
                  "level1",
                  "item0",
                  "odd",
                  "first"
                ],
                "Href": "/Page2",
                "Querystring": "",
                "NavigationTitle": {
                  "value": "Page2",
                  "editable": "Page2"
                }
              },
              {
                "Id": "cead36eb-cc39-401a-8ea7-37252d1a34f6",
                "Styles": [
                  "level1",
                  "item1",
                  "even",
                  "last"
                ],
                "Href": "/Page3",
                "Querystring": "",
                "NavigationTitle": {
                  "value": "Page3",
                  "editable": "Page3"
                }
              }
            ]
          }
        ],
        "headless-main": [

        ],
        "headless-footer": [
          
        ]
      }
    }
  }
}

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jbreuer
Copy link
Contributor

jbreuer commented Aug 21, 2024

I encountered a similar issue with handling empty strings and have submitted a pull request to address it. You can review the changes here: #12

@sc-ivanlieckens
Copy link
Collaborator

I have commented on #12 and I believe these 2 issues are indeed very similar and require a strategic architectural decision on the support of Custom Content Resolvers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants