feat: Implement migration for deprecated client fields in configuration#1219
Closed
palashgdev wants to merge 1 commit intomasterfrom
Closed
feat: Implement migration for deprecated client fields in configuration#1219palashgdev wants to merge 1 commit intomasterfrom
palashgdev wants to merge 1 commit intomasterfrom
Conversation
Contributor
|
kushalshit27
reviewed
Dec 1, 2025
| ClientExpressConfiguration, | ||
| ClientOrganizationRequireBehaviorEnum, | ||
| } from 'auth0'; | ||
| import _ from 'lodash'; |
Contributor
There was a problem hiding this comment.
Please import functions instead of _ for lodash.
kushalshit27
reviewed
Dec 1, 2025
Comment on lines
+383
to
+386
| const sanitizedClients = this.normalizeClientFields({ | ||
| clients, | ||
| fields: [{ newField: 'cross_origin_authentication', deprecatedField: 'cross_origin_auth' }], | ||
| }); |
Contributor
There was a problem hiding this comment.
move this logic under existing to
// Sanitize client fields
const sanitizeClientFields = (list: Client[]): Client[] => ....
kushalshit27
reviewed
Dec 1, 2025
| * and preventing loss of configuration data during schema transitions. | ||
| * @returns Client[] | ||
| */ | ||
| normalizeClientFields = ({ |
Contributor
There was a problem hiding this comment.
There is already a function named sanitizeClientFields . please be specific with the function name
kushalshit27
reviewed
Dec 1, 2025
Comment on lines
+393
to
+395
| * @description Maps deprecated client fields to their new counterparts and removes the deprecated field. | ||
| * If a deprecated field exists, its value is always used for the new field, ensuring data migration | ||
| * and preventing loss of configuration data during schema transitions. |
Contributor
There was a problem hiding this comment.
Logic is not correctly handled.
-
If only
cross_origin_authexists, use that value. (with a warn log) -
if both exists
cross_origin_auth: false
cross_origin_authentication: false
Use the value of cross_origin_authentication (with a warn log for cross_origin_auth)
- if both exists
cross_origin_auth: true
cross_origin_authentication: false
Use the value of cross_origin_authentication (with a warn log for cross_origin_auth)
Always give preference to the new key cross_origin_authentication.
kushalshit27
reviewed
Dec 1, 2025
Comment on lines
+407
to
+431
| }): Client[] => | ||
| clients.map( | ||
| (client) => | ||
| fields.reduce( | ||
| (acc, { deprecatedField, newField }) => { | ||
| const hasDeprecated = _.has(acc, deprecatedField); | ||
| const hasNew = _.has(acc, newField); | ||
|
|
||
| if (hasDeprecated) { | ||
| // If deprecated exists and new is missing, log a warning and copy the value | ||
| if (!hasNew) { | ||
| log.warn( | ||
| `Client '${client.name}': The '${deprecatedField}' field is deprecated. Migrating value to '${newField}'.` | ||
| ); | ||
| acc[newField] = acc[deprecatedField]; | ||
| } | ||
| // Remove the deprecated field | ||
| return _.omit(acc, deprecatedField); | ||
| } | ||
|
|
||
| return acc; | ||
| }, | ||
| { ...client } as Record<string, unknown> | ||
| ) as Client | ||
| ); |
Contributor
Author
|
closing in favor of #1223 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔧 Changes
This change specifically addresses backward compatibility for client application settings. We've enhanced the tool to reliably handle the old cross_origin_auth field and smoothly migrate its value to the new cross_origin_authentication field.
🔬 Testing
This change is purely a code style/best practice fix within a unit test. It ensures the existing logic for handling deprecated client fields during YAML load remains correct and reliable. No change in core functionality is expected.
📝 Checklist