Skip to content

Conversation

@zstarkebaum-bluemodus
Copy link

@zstarkebaum-bluemodus zstarkebaum-bluemodus commented Nov 13, 2025

Motivation

Adds support for tolerateMissingReferences parameter to migrate-content commands (run and snapshot), enabling users to continue exports when referenced items or assets are missing.

This parameter is passed through to the underlying @kontent-ai/migration-toolkit library (requires new version to be published).

⚠️ Dependency: This PR depends on kontent-ai/migration-toolkit#36 being merged and published as a new version first.

Use cases:

  • Content with broken references (deleted items/assets)

The parameter defaults to false to maintain backward compatibility.

Checklist

  • Code follows coding conventions held in this repo
  • Automated tests have been added (integration tests pending migration-toolkit update)
  • Tests are passing (will pass once new migration-toolkit version is published)
  • Docs have been updated (if applicable)
  • Temporary settings (e.g. variables used during development and testing) have been reverted to defaults

How to test

Prerequisites:

  • Requires new @kontent-ai/migration-toolkit version (see dependency note above)
  • For local testing before publish, update package.json:
    "@kontent-ai/migration-toolkit": "file:../migration-toolkit"

Manual CLI Testing:

  1. Build the project: npm run build

  2. Test migrate-content run with the new parameter:

node build/src/index.js migrate-content run \
  --environmentId=<your-env-id> \
  --apiKey=<your-api-key> \
  --tolerateMissingReferences
  1. Test migrate-content snapshot with the new parameter:
node build/src/index.js migrate-content snapshot \
  --environmentId=<your-env-id> \
  --apiKey=<your-api-key> \
  --tolerateMissingReferences
  1. Verify help text shows new parameter:
node build/src/index.js migrate-content run --help
node build/src/index.js migrate-content snapshot --help

Programmatic API Testing:

import { migrateContentRun, migrateContentSnapshot } from '@kontent-ai/data-ops';

// Run with tolerateMissingReferences
await migrateContentRun({
  environmentId: 'your-env-id',
  apiKey: 'your-api-key',
  tolerateMissingReferences: true
});

// Snapshot with tolerateMissingReferences
await migrateContentSnapshot({
  environmentId: 'your-env-id',
  apiKey: 'your-api-key',
  tolerateMissingReferences: true
});

@zstarkebaum-bluemodus zstarkebaum-bluemodus changed the title feat: add --tolerateMissingReferences option to migrateContent commands New migrate content option: Tolerate Missing References Nov 13, 2025
@IvanKiral
Copy link
Contributor

Thanks for the PR, When the migraiton-toolkit will be released I wii look into it :)

Copy link
Contributor

@IvanKiral IvanKiral left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I apologize for a delayed review.

There are few inconsistencies as this PR was created before updates in migration toolkit? Would you be able to fix those before we merge it? Also could you please update the version of migration toolkit as it is already released?

Thanks for the PR :)

.option("tolerateMissingReferences", {
type: "boolean",
describe:
"When enabled, missing items and assets will be skipped instead of throwing errors.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skip missing item and asset references instead of throwing errors.

"A filter to obtain a subset of items codenames. See Delivery API documentation for more information.",
conflicts: itemsFilterParams.filter((p) => p !== "filter"),
})
.option("tolerateMissingReferences", {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rename it so it is consistent with migration toolkit - skipMissingReferences

import { migrateContentRun } from "../../../src/modules/migrateContent/migrateContentRun.ts";

// Mock the migration-toolkit
vi.mock("@kontent-ai/migration-toolkit", () => ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreaciate that you wrote tests, though, I don't think this test is necessary. It would be better to have integration test, though those I would need to write myself :D

please remove this file.

@zstarkebaum-bluemodus
Copy link
Author

@IvanKiral I will make these updates. Thanks!

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

Successfully merging this pull request may close these issues.

2 participants