Skip to content

cloneToNewSpace fails due to a locale validation #24

@dchem

Description

@dchem

Observed:

Error in uploading the space:  ValidationFailed: {
  "request": {
    "url": "https://api.contentful.com:443/spaces/<space>/locales",
    "headers": {
      "Accept": "application/json, text/plain, */*",
      "Content-Type": "application/vnd.contentful.management.v1+json",
      "X-Contentful-User-Agent": "contentful-management.js/1.3.1",
      "Authorization": "Bearer CFPAT-<token>",
      "user-agent": "node.js/v7.7.4",
      "Accept-Encoding": "gzip",
      "Content-Length": 119
    },
    "method": "post",
    "payloadData": "{\"code\":\"es-US\",\"name\":\"Spanish (United States)\",\"contentManagementApi\":true,\"contentDeliveryApi\":true,\"optional\":true}"
  },
  "status": 422,
  "statusText": "Unprocessable Entity",
  "requestId": "<id>",
  "message": "The resource you sent in the body is invalid.",
  "details": {
    "errors": [
      {
        "name": "taken",
        "path": "display_code",
        "value": "es-US"
      }
    ]
  }
}

Desired:
422 errors of this sort, which occurs at

spaceImport(uploadOptions)
      .then((finalOutput) => {
        console.log(chalk.green('\n *** All Data Imported successfully *** \n')) 
      })
      .catch((err) => {
        console.log(chalk.red('Error in uploading the space: ', err))
      })

Should be handled so that instead of catch, reject is handled in the spaceImport promise.

Steps to replicate:
Run the scripts

npm run cloneToNewSpace

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions