contentful / contentful-cli

The official Contentful command line interface. Use Contentful features straight from the command line!
https://www.contentful.com/developers/docs/tutorials/cli/
MIT License
328 stars 61 forks source link

CLI Export outputting bad JSON #2761

Open augur-absorb opened 1 month ago

augur-absorb commented 1 month ago

Expected Behavior

contentful space export --config migration-configs/export-contentModel-layout.json

Will export a clean JSON representing the Model (layout) I want to export using the following config:

{
    "spaceId": "",
    "environmentId": "master",
    "managementToken": "",
    "queryEntries": "sys.id=layout",
    "skipContentModel": "false",
    "skipContent": "true",
    "skipRoles": "true",
    "skipTags": "true",
    "skipWebhooks": "true"
}

Actual Behavior

The output is a mess, here is a snippet

{
  "contentTypes": ,
  [
    {
      "sys": {
        "space": {
          "sys": {
            "type": "Link""linkType": ,
            "Space""id": ,
            "92yop6rduul9"
          }
        } "id": ,
        "snippets""type": ,
        "ContentType""createdAt": ,
        "2023-02-03T16:31:58.365Z""updatedAt": ,
        "2023-03-16T22:13:19.937Z""environment": ,
        {
          "sys": {
            "id": "master""type": ,
            "Link""linkType": ,
            "Environment"
          }
        } "publishedVersion": ,
        9 "publishedAt": ,
        "2023-03-16T22:13:19.937Z""firstPublishedAt": ,
        "2023-02-03T16:32:00.085Z""createdBy": ,
        {
          "sys": {
            "type": "Link""linkType": ,
            "User""id": ,
            "5v7vAL4VgrlYaYWFzopg4e"
          }
        } "updatedBy": ,
        {
          "sys": {
            "type": "Link""linkType": ,
            "User""id": ,
            "5ycc1mTy0xRipRZEDU9BUy"
          }
        } "publishedCounter": ,
        5 "version": ,
        10 "publishedBy": ,
        {
          "sys": {
            "type": "Link""linkType": ,
            "User""id": ,
            "5ycc1mTy0xRipRZEDU9BUy"
          }
        } "urn": ,
        "crn:contentful:::content:spaces/92yop6rduul9/environments/master/content_types/snippets"
      } "displayField": ,
      "name""name": ,
      "Snippets""description": ,
      "Snippets are reusable blocks of content that can be added to Pages or Layouts.""fields": ,
      [
        {
          "id": "name""name": ,
          "Name""type": ,
          "Symbol""localized": ,
          false "required": ,
          false "validations": ,
          [] "disabled": ,
          false "omitted": ,
          false
        },
        {
          "id": "content""name": ,
          "Content""type": ,
          "RichText""localized": ,
          false "required": ,
          false "validations": ,
          [
            {
              "enabledNodeTypes": [
                "heading-1""heading-2",
                "heading-3",
                "heading-4",
                "heading-5",
                "heading-6",
                "ordered-list",
                "unordered-list",
                "hr",
                "blockquote",
                "embedded-entry-block",
                "embedded-asset-block",
                "table",
                "hyperlink",
                "entry-hyperlink",
                "asset-hyperlink",
                "embedded-entry-inline"
              ]
            },
            {
              "enabledMarks": [
                "bold""italic",
                "underline",
                "code"
              ]
            }
          ],
          ,
          "disabled": false "omitted": ,
          false
        }
      ]
    },

I am expecting to run the command, as I have many times in the past, and to produce a well-structured JSON.

Possible Solution

Steps to Reproduce

  1. Install Contentful CLI
  2. Setup Export Config
  3. Run command contentful space export --config migration-configs/export-contentModel-layout.json
  4. Check output.

Context

Environment

tptech commented 1 month ago

Have experienced exactly the same thing. There appears to be extraneous commas all throughout the *-export.json file.

camimora commented 1 month ago

Hello! Same issue here on Mac Sonoma. I tried with several previous versions of the CLI but same result.

nickamckenna commented 1 month ago

I also have this problem (this is the first few lines of a 20,000,000 line export):

{
  "contentTypes":,
   [
    {"sys":
       {"space":
         {"sys":
           {"type":
            "Link" "linkType":,
            "Space" "id":,
            "xxxxxxxxxx"
          }
        } "id":,
        "resource" "type":,
        "ContentType" "createdAt":,
        "2021-11-09T18:00:11.040Z" "updatedAt":,
        "2022-11-14T15:33:06.034Z" "environment":,
         {"sys":
           {"id":
            "master" "type":,
            "Link" "linkType":,
            "Environment"
          }
        } "publishedVersion":,
        31 "publishedAt":,

There are properties with no values and it looks like some values are being outputted in the wrong place.

This means that we can't back up Contentful at the moment. And we can't create a new web site based on a previous web site.

Running on Windows 11 with the latest version of the CLI.

nickamckenna commented 1 month ago

Duplicate of https://github.com/contentful/contentful-cli/issues/2760

chris-cazaly-coop commented 1 month ago

A recent contentful-cli release of v3.3.12 fixed this issue for us