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

Ignore unrelated errors in migrations #186

Open
gkulasik-livongo opened this issue May 14, 2019 · 5 comments
Open

Ignore unrelated errors in migrations #186

gkulasik-livongo opened this issue May 14, 2019 · 5 comments

Comments

@gkulasik-livongo
Copy link

gkulasik-livongo commented May 14, 2019

Expected Behavior

There is some override or catching mechanism within a migration block that can ignore errors (such as notResolvable) that are not related to the data being migrated.

Actual Behavior

Situation: I am migrating some text content (simple text change with transformEntries) and the contentType has a reference field to an asset (image). For 2 out of 2000+ entries there is a bad reference which fails the migration. I cannot change the content to fix those references because those are controlled by a different team. I am only able to migrate/edit the text fields. My migration fails because of these bad references that I cannot change.

Possible Solution

Is there, or can there be, a way (within the JS CLI migration tool) to 'ignore' exceptions and save content (override) or to catch exceptions and ignore so that the entire migration is not marked as a failure.

This can be a flag on the migration CLI call:

contentful space migration -s XXX -e XXX test_migration.js --mt XXX --ignore-errors

or an additional option to transformEntries:

migration.transformEntries({
            contentType: "ContentType",
            from: ['Field1'],
            to: ['Field2'],
            ignoreValidationErrors: true,
            ...

Steps to Reproduce

  1. Setup a content type with a reference field (image asset for example)
  2. Create a single valid content entry of that content type
  3. Delete the referenced image (don't remove the reference on the content entry)
  4. Try to migrate the content using transformEntries (or any other migration)
  5. Migration will be marked as a failure with message similar to:
UnresolvedLinks: {
  "status": 422,
  "statusText": "Unprocessable Entity",
  "message": "Validation error",
  "details": {
    "errors": [
      {
        "name": "notResolvable",
        "link": {
          "type": "Link",
          "linkType": "Asset",
          "id": "XXXXX"
        },
        "path": [
          "fields",
          "images",
          "en-US",
          0
        ]
      }
    ]
  },
  "request": {
    "url": "https://api.contentful.com:443/spaces/XXXX/environments/XXX/entries/XXXXX/published",
    "headers": {
      "Accept": "application/json, text/plain, */*",
      "Content-Type": "application/vnd.contentful.management.v1+json",
      "X-Contentful-User-Agent": "app contentful.cli/0.26.5; feature space-migration; sdk contentful-management.js/5.2.1; platform node.js/v10.7.0; os macOS/18.5.0;",
      "Authorization": "Bearer ...81aee",
      "user-agent": "node.js/v10.7.0",
      "Accept-Encoding": "gzip",
      "X-Contentful-Version": 4,
      "X-Contentful-Content-Type": "imagePage"
    },
    "method": "put"
  },
  "requestId": "e47cf5f42d6be5407cd04809e5b28e71"
}
    at errorHandler (/usr/local/lib/node_modules/contentful-cli/node_modules/contentful-migration/node_modules/contentful-management/dist/contentful-management.node.js:13173:15)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Context

I think the context was covered a bit in previous sections but essentially I need to apply a universal change to a text field and publish the updated text. The migration fails because of an unresolved reference (asset) unrelated to the change I am making.

I generally support the validation and think it should be on by default but really need there to be an override to accomplish what we are looking to do given there are many people's hands in the content and we cannot have our CI fail because one entry has a bad reference, it is ok if it gets skipped and we log the issue but other migrations need to run afterward which get blocked by this failure/validation.

Environment

  • Node Version: v10.7.0
  • Package Manager Version: 6.3.0
  • Operating System: Mac OS 64 bit (also sometime Linux)
  • Contentful CLI version: 0.26.5
@freder
Copy link

freder commented May 29, 2019

I'm also currently running into notResolvable errors.

@yvesgurcan
Copy link

I am running into the same issue when modifying a content type that has a link to an entry with an image into that linked entry to get the image itself. When running into broken references to images, the migration fails and the content model ends up being half-modified since the first steps of the migration are indeed executed but not the ones after the step with the entities that do not resolve, which is most likely the least desirable state.

@acn-husnie-edres
Copy link

acn-husnie-edres commented Nov 6, 2023

I also encountered the same issue, need to manually fix the content that is not related to migration. LOL

what is the status of this issue?

image

@sergiusticiffw
Copy link

I have the same issue. any updates here?

@ickeundso
Copy link

Hi Contentful Team no answer yet , this issue is 5 years open. Every time im facing an issue like that I have to impolite some exclude list handling to deal with that. Not only an ignore error switch would be nice to have , also an error report which entry has been skipped.

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

No branches or pull requests

7 participants