fix: warn and skip deprecated guardian phone provider on 403 during import#1429
fix: warn and skip deprecated guardian phone provider on 403 during import#1429harshithRai wants to merge 2 commits into
Conversation
| data as Management.SetGuardianFactorsProviderPhoneRequestContent | ||
| ); | ||
| } catch (err) { | ||
| if (isFeatureUnavailableError(err) || isForbiddenFeatureError(err, this.type)) { |
There was a problem hiding this comment.
Hey, curious about the hooks_not_allowed errorCode here, is this specific to the phone provider endpoint, or could it have been carried over from somewhere else?
Asking because I'd expect Auth0 to return something like legacy_mfa_phone_provider_not_allowed here rather than a hooks related errorCode
If it's not needed, we could simplify isFeatureUnavailableError to just handle the 404 case and let isForbiddenFeatureError take care of 403s (which it already does)
Totally a nit though, not a blocker!
There was a problem hiding this comment.
Good catch! you're right. hooks_not_allowed was pre-existing and redundant since isForbiddenFeatureError already handles any 403. Simplified isFeatureUnavailableError to just the 404 case in both handlers. Pushed the change 👍
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1429 +/- ##
=========================================
Coverage ? 80.20%
=========================================
Files ? 163
Lines ? 7542
Branches ? 1665
=========================================
Hits ? 6049
Misses ? 805
Partials ? 688 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🔧 Changes
Importing a YAML configuration exported from an older tenant into a newer tenant could abort the entire import when the legacy per-factor phone provider API is disabled on the target tenant. The Management API returns
403 legacy_mfa_phone_provider_not_allowed("Insufficient privileges to use this deprecated feature"), and the import failed hard during theprocessChangesstage.The export/
getTypepath already handled such 403s gracefully viaisForbiddenFeatureError(warn + skip). This change wires the same behavior into the import/processChangespath for the guardian phone resources, so a deprecated/forbidden feature now logs a warning and is skipped instead of failing the deployment.guardianFactorTemplates,guardianPhoneFactorSelectedProvider,guardianPhoneFactorMessageTypes: wrapped the write API calls inprocessChangesto catch a deprecated/forbidden 403 and skip instead of throwing.isForbiddenFeatureError(utils): cleaned up the warning to read the human-readablemessageanderrorCodefrom the response body (originalError.response.body) instead of logging the full serialized error blob. This improves logging for every 403-skippable resource that uses the helper.guardianPhoneFactorSelectedProvider,guardianPhoneFactorMessageTypes: simplifiedisFeatureUnavailableErrorto only handle the 404 (endpoint-not-available) case. Thehooks_not_allowed/voice_mfa_not_allowed403 branches were redundant sinceisForbiddenFeatureErroralready catches any 403 - these 403s now emit a warn log instead of being skipped silently, consistent with other forbidden-feature handling.📚 References
legacy_mfa_phone_provider_not_allowedis returned at runtime by the Management API but is not documented in the OpenAPI spec or typed in auth0-node (v6.x) - verified againstmanagement-api-oas.json. The fix therefore treats any 403 on these guardian phone endpoints as a skippable deprecated/forbidden feature rather than matching a specific errorCode string.GET/PUT/guardian/factors/sms/templatesare documented as deprecated in favor of the phone-templates endpoints: https://auth0.com/docs/api/management/v2/guardian/put-factor-phone-templates🔬 Testing
Verified end-to-end against a live tenant with "Use Tenant-Level Messaging Provider" enabled (which disables the legacy per-factor phone API):
a0deploy importwithguardianPhoneFactorSelectedProviderin the YAML failed withProblem running command import during stage processChanges when processing type guardianPhoneFactorSelectedProviderand exited with code1.warn: Insufficient privileges to use this deprecated feature. (legacy_mfa_phone_provider_not_allowed) - Skipping guardianPhoneFactorSelectedProvider, reportedImport Successful, and exited with code0.Unit tests added/updated:
guardianFactorTemplates: verifiesprocessChangeswarns and skips on a legacy-feature 403 instead of throwing.isForbiddenFeatureError: verifies the cleaned-up warning message and errorCode are extracted from the response body.guardianPhoneFactorSelectedProvider/guardianPhoneFactorMessageTypes: existing "endpoint is disabled for tenant" tests still pass, now routing the 403 throughisForbiddenFeatureError(returns null/skips, with a warn log).📝 Checklist