Skip to content

Conversation

@palashgdev
Copy link
Contributor

🔧 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

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

@palashgdev palashgdev self-assigned this Nov 29, 2025
@palashgdev palashgdev added feature request javascript Pull requests that update javascript code labels Nov 29, 2025
@kushalshit27
Copy link
Contributor

kushalshit27 commented Dec 1, 2025

  • Please update pr title for this fix
  • The branch name format is not as per the guidelines
  • please add relevant label if needed

@kushalshit27 kushalshit27 removed feature request javascript Pull requests that update javascript code labels Dec 1, 2025
ClientExpressConfiguration,
ClientOrganizationRequireBehaviorEnum,
} from 'auth0';
import _ from 'lodash';
Copy link
Contributor

Choose a reason for hiding this comment

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

Please import functions instead of _ for lodash.

Comment on lines +383 to +386
const sanitizedClients = this.normalizeClientFields({
clients,
fields: [{ newField: 'cross_origin_authentication', deprecatedField: 'cross_origin_auth' }],
});
Copy link
Contributor

Choose a reason for hiding this comment

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

move this logic under existing to

// Sanitize client fields
    const sanitizeClientFields = (list: Client[]): Client[] => ....

* and preventing loss of configuration data during schema transitions.
* @returns Client[]
*/
normalizeClientFields = ({
Copy link
Contributor

Choose a reason for hiding this comment

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

There is already a function named sanitizeClientFields . please be specific with the function name

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.
Copy link
Contributor

@kushalshit27 kushalshit27 Dec 1, 2025

Choose a reason for hiding this comment

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

Logic is not correctly handled.

  • If only cross_origin_auth exists, 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.

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
);
Copy link
Contributor

@kushalshit27 kushalshit27 Dec 1, 2025

Choose a reason for hiding this comment

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

reduce complexity, read more on link

@palashgdev
Copy link
Contributor Author

closing in favor of #1223

@palashgdev palashgdev closed this Dec 2, 2025
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.

3 participants