fix: catch feature_not_enabled via err.body.errorCode and 400 status in organizations handler - #1482
Open
harshithRai wants to merge 2 commits into
Open
fix: catch feature_not_enabled via err.body.errorCode and 400 status in organizations handler#1482harshithRai wants to merge 2 commits into
harshithRai wants to merge 2 commits into
Conversation
…in organizations handler
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1482 +/- ##
=======================================
Coverage 80.81% 80.82%
=======================================
Files 163 163
Lines 7805 7806 +1
Branches 1741 1742 +1
=======================================
+ Hits 6308 6309 +1
Misses 797 797
Partials 700 700 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
harshithRai
marked this pull request as ready for review
September 3, 2026 07:43
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
Organization export/import could fail on tenants without the org-to-app or discovery-domains entitlement. The handler tried to swallow the
feature_not_enablederror but the guard was wrong in two ways:err.errorCode, which is alwaysundefined. The auth0 SDK v6.3.0ManagementErrorexposes the API code aterr.body.errorCode, noterr.errorCode.403. Some tenants now return400forfeature_not_enabled, so the check missed those entirely.With both conditions failing, the error was rethrown and aborted the run during
processChanges(which callsgetTypefirst).This adds a small
isFeatureNotEnabled(err)helper that reads the code fromerr.body.errorCodeand matches it regardless of HTTP status (400 or 403). Both catch blocks in the organizations handler (org-client associations and discovery domains) now use it and skip the unavailable data gracefully with a debug log instead of failing.No data-shape changes: no config schema, JSON, or YAML output formats were modified. Behavior change is limited to error handling on unentitled tenants.
🔬 Testing
400whose code lives onerr.body.errorCode. It fails against the previous code and passes with the fix.tscandeslintclean.export, read-only) that has organizations and does not have the org-to-app entitlement. Before the fix this export threwfeature_not_enabled; after the fix it completes with exit 0, logs "Org-to-app entitlement is not enabled for this tenant. Skipping org-client associations." once per org, and still exports the organizations.📝 Checklist