Determine if OrangeDamApi::getSearchApiData() and getDataTableData() should return data only for valid content types?

Created on 30 January 2024, 5 months ago

Problem/Motivation

Using drush orange-dam:queue-content-item it seems to be possible to queue data for a content type that is not in the migration configuration. There are other situations where code can call OrangeDamApi::getContentItem() and potentially try to retrieve data from content types that are outside the scope of the defined migration.

Should those methods validate that the returned content type is an expected object type? Not validating means the queue can, over time, end up with items that can never be migrated and were never intended to be retrieved.

Adding validation seems pretty sensical to me, but that might be only because I don't see a business case for retrieving an item by identifier that we are not actually interested in migrating. But perhaps there are situations where that is actually desired? (Just because I can't see it doesn't mean it doesn't exist).

Steps to reproduce

1. Look up the id of a content item of a content type in Orange Logic that has not been configured for migration.
2. Queue it (easiest to do with drush orange-dam:queue-content-item ).

Proposed resolution

Add a step in OrangeDamApi::getSearchApiData() and getDataTableData() where we check the returned content type and compare it to our array of valid content types. Throw exception, catch and log it.

Remaining tasks

1. Understand the full ramifications of adding this restriction. (Is it better to just clean up the queue from time to time and remove invalid objects rather than enforce more rules?)
2. Understand if adding validation at these two methods will definitively resolve the issue or if there are gaps. This will inform point 1.
3. Depending on outcome of 1 + 2, either add validation logic, or add a configurable cron task to clean up the queue of orange_dam_migration:* items that are unexpected.

πŸ“Œ Task
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States apotek

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024