[SOLVED] CLI sync in deletes content fields that has components fields

I have…

  • Checked the logs and have uploaded a log file and provided a link because I found something suspicious there. Please do not post the log file in the topic because very often something important is missing.

I’m submitting a…

  • Regression (a behavior that stopped working in a new release)
  • Bug report
  • Performance issue
  • Documentation issue or request

Current behavior

Seems that dotnet sq sync in deletes all contents field values of type “Components”.

Expected behavior

I expect I can do a dotnet sq sync out and then a dotnet sq sync in again.

In real world I hope to do sync out, push to git, pull on other machine and then sync in.

Minimal reproduction of the problem

  1. Create schema “test-component” with a single “text” field named “title”:

    {
      "previewUrls": {},
      "properties": {
        "validateOnPublish": false
      },
      "scripts": {},
      "isPublished": true,
      "fieldRules": [],
      "fieldsInLists": [],
      "fieldsInReferences": [],
      "fields": [
        {
          "name": "title",
          "properties": {
            "isRequired": false,
            "isRequiredOnPublish": false,
            "isHalfWidth": false,
            "fieldType": "String",
            "createEnum": false,
            "editor": "Input",
            "inlineEditable": false,
            "isEmbeddable": false,
            "isUnique": false,
            "contentType": "Unspecified"
          },
          "isLocked": false,
          "isHidden": false,
          "isDisabled": false,
          "partitioning": "invariant"
        }
      ],
      "type": "Component"
    }
    
  2. Create schema “test-content” with a single “components” field named “myTestComponents”:

    {
      "previewUrls": {},
      "properties": {
        "validateOnPublish": false
      },
      "scripts": {},
      "isPublished": true,
      "fieldRules": [],
      "fieldsInLists": [],
      "fieldsInReferences": [],
      "fields": [
        {
          "name": "myTestComponents",
          "properties": {
            "isRequired": false,
            "isRequiredOnPublish": false,
            "isHalfWidth": false,
            "fieldType": "Components",
            "calculatedDefaultValue": "EmptyArray",
            "minItems": 0,
            "maxItems": 10,
            "schemaIds": ["8e8771e1-135c-468b-b3d4-d7acc934b2b2"]
          },
          "isLocked": false,
          "isHidden": false,
          "isDisabled": false,
          "partitioning": "invariant"
        }
      ],
      "type": "Default"
    }
    
  3. Create a “test-content” item and add 3 components with the title “a”, “b”, “c” in the “myTestComponents” field.

  4. dotnet sq sync out --app cli-test .\cli-sync-issue\data

  5. files on disk looks fine:

    {
      "$schema": "./../__json/contents.json",
      "contents": [
        {
          "schema": "test-content",
          "data": {
            "myTestComponents": {
              "iv": [
                {
                  "schemaId": "test-component",
                  "title": "a",
                  "schemaName": "test-component"
                },
                {
                  "schemaId": "test-component",
                  "title": "b",
                  "schemaName": "test-component"
                },
                {
                  "schemaId": "test-component",
                  "title": "c",
                  "schemaName": "test-component"
                }
              ]
            }
          },
          "id": "62bf8283-0831-4ada-be6a-0332b5aec46e",
          "status": "Published"
        }
      ],
      "sourceApp": "cli-test",
      "sourceUrl": "https://cloud.squidex.io/"
    }
    
  6. dotnet sq sync in --app cli-test .\cli-sync-issue\data:

  7. output from cli:

    * STEP 4 of 7: Importing Contents started
    
    Upserting #0/0...                       succeeded.
    
    * STEP 4 of 7: Importing Contents completed
    
  8. the “myTestComponents” field is now empty :frowning:

    {
      "id": "62bf8283-0831-4ada-be6a-0332b5aec46e",
      "createdBy": "subject:672e1301580f3c300b8cd4a2",
      "lastModifiedBy": "client:cli-test:default",
      "data": {
        "myTestComponents": {
          "iv": []
        }
      }
      ...
    }
    

Environment

  • Self hosted with docker
  • Self hosted with IIS
  • Self hosted with other version
  • Cloud version

Version: 7.15.0

Browser:

  • Chrome (desktop)
  • Chrome (Android)
  • Chrome (iOS)
  • Firefox
  • Safari (desktop)
  • Safari (iOS)
  • IE
  • Edge

Others: no

Thanks for the detailed explanation. I have pushed a fix. The problem was that the CLI converted schema ID to schema names but never back to schema IDs.

1 Like

This topic was automatically closed after 16 hours. New replies are no longer allowed.