Skip to content

retry dictionary registration#201

Open
leoraba wants to merge 42 commits into
feat/dictionary_migrationfrom
feat/retry_failed_migrations
Open

retry dictionary registration#201
leoraba wants to merge 42 commits into
feat/dictionary_migrationfrom
feat/retry_failed_migrations

Conversation

@leoraba
Copy link
Copy Markdown
Contributor

@leoraba leoraba commented May 4, 2026

Description

Note: This PR is a Part # 3 of a series of a PRs to implement Dictionary migration.

It enables the possibility to retry "failed" Dictionary migration by adding a force flag on the Dictionary Registration endpoint.

Details:

  • Updated POST /dictionary/register endpoint to accept an optional query param force to Re-register the current active dictionary on the category and retries the data migration.

Related tickets:

This PR depends on:

leoraba added 30 commits January 9, 2026 11:10
@leoraba leoraba requested review from JamesTLopez and joneubank May 4, 2026 16:48
Comment on lines +49 to +50
409:
$ref: '#/components/responses/StatusConflict'
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

if registering the same Dictionary for the category then it throws a 409 error, unless the "force" flag is true.

@leoraba leoraba linked an issue May 4, 2026 that may be closed by this pull request
Comment on lines +9 to +15
- name: force
description: Re-registers the current active dictionary on the category and retries the data migration.
in: query
required: false
schema:
type: boolean
default: false
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add more detail about this behaviour? I don't know what re-registering a dictionary will do. Is this the same as initiating a migration? If the dictionary version is the same as the current dictionary will it run the migration with the intention of revalidating the data (should have no impact on the current data state)?


If a category is already using the same dictionary name and version, registration returns `409 Conflict`.

Set the `force` query parameter to `true` to allow re-registration and trigger a migration (or retry) to revalidate existing category data against that dictionary.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Repeating my comment since this is the full documentation about registering dictionaries:

Can you add more detail about this behaviour? I don't know what re-registering a dictionary will do. Is this the same as initiating a migration? If the dictionary version is the same as the current dictionary will it run the migration with the intention of revalidating the data (should have no impact on the current data state)?

const newMigration: NewDictionaryMigration = {
categoryId,
fromDictionaryId,
fromDictionaryId: fromDictionaryId ?? toDictionaryId,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is confusing to read - perhaps we should leave it as required and the caller can indicate that fromDictionaryId value should be the same value as toDictionaryId. I would not expect the migration service to assume that if from value is not provided you reuse the to value.

Comment on lines +140 to +164
if (forceRegistration) {
logger.info(
LOG_MODULE,
`Force flag is true, initiating migration for Category '${foundCategory.name}'
with Dictionary '${savedDictionary.name}' version '${savedDictionary.version}'`,
);

const resultMigration = await initiateMigration({
categoryId: foundCategory.id,
toDictionaryId: savedDictionary.id,
userName: username || '',
});

if (!resultMigration.success) {
const errorMessage = `Failed to initiate migration for category '${categoryName}' with error: ${resultMigration.data}`;
logger.error(LOG_MODULE, errorMessage);
throw new Error(errorMessage);
}

return { dictionary: savedDictionary, category: foundCategory, migrationId: resultMigration.data };
}

throw new StatusConflict(
`Category '${categoryName}' with Dictionary '${savedDictionary.name}' version '${savedDictionary.version}' already exists`,
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is not very DRY, a lot of repeated code from the else block. The only difference is omitting the fromDictionaryId and changed log statements. Is there a way to write this that won't open us up to a future code change that is only made in one branch of this if statement?

Base automatically changed from feat/get_migration_endpoints to feat/dictionary_migration May 12, 2026 16:56
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.

[Part 3 - Data migration] Retry migration

2 participants