fix: organization creation response handling and add ID validation#1365
Merged
kushalshit27 merged 4 commits intomasterfrom Apr 20, 2026
Merged
fix: organization creation response handling and add ID validation#1365kushalshit27 merged 4 commits intomasterfrom
kushalshit27 merged 4 commits intomasterfrom
Conversation
- src/tools/auth0/handlers/organizations.ts: Add error handling for missing organization ID on creation. - src/tools/auth0/handlers/organizations.ts: Refactor to use createdId for connection and grant associations. - test/tools/auth0/handlers/organizations.tests.js: Simplify promise resolution in test cases.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1365 +/- ##
==========================================
- Coverage 80.10% 80.08% -0.03%
==========================================
Files 152 152
Lines 6213 6216 +3
Branches 1290 1291 +1
==========================================
+ Hits 4977 4978 +1
- Misses 702 703 +1
- Partials 534 535 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ankita10119
requested changes
Apr 20, 2026
|
|
||
| if (!created.id) { | ||
| log.error( | ||
| `Organization "${organization.name}" was created but the response did not include an ID. Skipping connection/grant association.` |
Contributor
There was a problem hiding this comment.
Instead of silently returning here, should we not throw the error?
As the current behaviour creates partial state(org exists, connection missing) with no error propagation
- src/tools/auth0/handlers/organizations.ts: Replace log error with throw for missing organization ID
…tion - test/tools/auth0/handlers/organizations.tests.js: throw error in create method when deleting organizations - test/tools/auth0/handlers/organizations.tests.js: update stage function to handle empty organizations array
ankita10119
approved these changes
Apr 20, 2026
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
Root cause:
After the node-auth0 v4→v5 upgrade,
client.organizations.create()changed from returning { data: org } to returning org directly. The organizations handler was the only one still destructuring { data: created }, causing created to be undefined — hence TypeError: Cannot read properties of undefined (reading 'id') when it tried to use created.id to add connections.Fixed:
OrganizationsHandler.createOrganization()to correctly extract the created organization from the API response. The client method now returns the organization object directly instead of a nested{ data }structure.📚 References
🔬 Testing
test/tools/auth0/handlers/organizations.tests.jshave been updated to verify the corrected response structure from the organizations client.📝 Checklist