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

Block Grid and Block list unexpected errors when using root site #694

Open
MrPels opened this issue Dec 18, 2024 · 3 comments
Open

Block Grid and Block list unexpected errors when using root site #694

MrPels opened this issue Dec 18, 2024 · 3 comments

Comments

@MrPels
Copy link

MrPels commented Dec 18, 2024

Bug Description
I have a setup where one web project serves as the baseline (root), and another web project consumes shared resources via uSync.

The issue arises with the block grid and block list data types. When these are created in the baseline project, errors occur in the consuming project when attempting to use the export features in the back office. Additionally, since version 15 of uSync/Umbraco, the consuming web project is unable to save added local blocks to a shared block grid data type. The same error is triggered as with the export issue when a save is attempted.

To clarify, baseline (root) can export block grid data types with uSync, consuming web project is hindered with errors attempting to export with uSync.

A secondary issue is that exports from the consuming project generate configuration files for the block list, even if no changes have been made to the data types. This behavior differs from how other document types or data types are handled. I would only expect uSync to create local config files when i change something in the shared data types in the consuming website.

To Reproduce
To reproduce the problem, one could run the simple repo i have created here.

https://github.com/MrPels/UmbracoBaselineDemo

The project is created on latest version of Umbraco 15.1.1 and uSync 15.1.0

Baseline is acting as the root web project, and has some simple document types created under "Document Types" -> "Shared" and also a block grid and block list data types created under "Data Types" -> "Shared Data Types" used to illustrate the problem.

The Child web project is acting as the consuming project. It has a local document type created under "Document Types" -> "Local".

Steps to reproduce export behavior:

  1. Run Child web project
  2. Initialize sqllite database
  3. Login
  4. Navigate to "Settings"
  5. Navigate to "uSync"
  6. Try "Export" in the "Settings" section.

Steps to reproduce adding local block to shared data type:

  1. Run Child web project
  2. Initialize sqllite database
  3. Login
  4. Navigate to "Settings"
  5. Navigate to "Data Types" -> "Shared Data Types"
  6. Attempt to add "galleryBlock" to "Shared Block Grid" data type.
  7. Try saving the data type.

Expected behavior
I expect to be able to use the "export" function when a solution has Block Grid and Block List data types that originates from a root site.
The consuming web site, should also be able to add local blocks to a shared data type and be able to save the change, that result in a local config file.

Screenshots
The images are from the consuming website.

Export Shared Block Grid Error

Block Grid Error

About the Site

  • Umbraco Version: 15.1.1
  • uSync Version: 15.1.0
  • Browser - Chrome: 131.0.6778.140

Additional context
The Umbraco log does contain an error log, but not with much context as it is to generic. You can view it directly in the backoffice after triggering the export error or attempt at saving a local block to the Shared Block Grid data type.

Root site is configured with the following uSync setting

  "uSync": {
    "Settings": {
      "IsRootSite": true,
      "ImportAtStartup": "Settings"
    },
    "Sets": {
      "Default": {
        "Handlers": {
          "ContentHandler": {
            "Enabled": false
          },
          "MediaHandler": {
            "Enabled": false
          }
        }
      }
    }
  },

Consuming site is configured with the following uSync setting

  "uSync": {
    "Settings": {
      "LockRoot": false,
      "ImportAtStartup": "Settings",
      "Folders": [
        "~/../UmbracoBaseline/uSync/Root",
        "uSync/v15"
      ]
    },
    "Sets": {
      "Default": {
        "Handlers": {
          "ContentHandler": {
            "Enabled": false
          },
          "MediaHandler": {
            "Enabled": false
          }
        }
      }
    }
  },
@MrPels
Copy link
Author

MrPels commented Jan 3, 2025

Hi @KevinJump, i have made a branch with a possible solution to the problem. But it does not seem like i am having problems with creating a PR.

@MrPels
Copy link
Author

MrPels commented Jan 3, 2025

The underlying problem seems to originate from "GetJsonArrayDifferences" where TryGetPropertyAsObject always fails when working with block grid, in context of a root + target project.

After getting the property "contentElementTypeKey" inb the input JsonObject object and parsing it to a JsonNode object it seem to be of type JsonValueKind.String resulting in you cannot use .AsObject() in the extension method "TryGetPropertyAsObject" which is only able for correctly formatted json strings, therefore it always fails the cast resulting in the catch statement always returning false.

Afterwards the fallback seem to set multiple empty string keys for the dictionaries used to compare blocks between root and target resulting in the described error in the github issue. "That key has already been added" as each block tries to set a empty string key.

@KevinJump
Copy link
Owner

Hi @MrPels , thanks for all the info, back from leave looking at this today!

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

No branches or pull requests

2 participants