fix: strip read-only field from roles to fix export/import round-trip (#1439) - #1445
Draft
harshithRai wants to merge 1 commit into
Draft
fix: strip read-only field from roles to fix export/import round-trip (#1439)#1445harshithRai wants to merge 1 commit into
harshithRai wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1445 +/- ##
=======================================
Coverage 80.36% 80.37%
=======================================
Files 163 163
Lines 7595 7598 +3
Branches 1677 1677
=======================================
+ Hits 6104 6107 +3
Misses 797 797
Partials 694 694 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
Tenant roles could not be round-tripped:
export→importfailed with a400.The roles GET endpoint returns a read-only
typefield (e.g.tenant), but the roles create/update endpoints reject it withPayload validation error: 'Additional properties not allowed: type'. The handler wrote the exportedtypestraight back on import, breaking the round-trip.This strips
typein two places insrc/tools/auth0/handlers/roles.ts:getType()(export) - omittypefrom exported output so new exports stay round-trippable.createRole()/updateRole()(import write paths) - striptypebefore calling the API so files that were already exported with the field (pre-fix) can still be imported without re-exporting.Shape (export output)
The only shape change is on the export side - the
typefield no longer appears on roles. Import accepts both shapes (with or withouttype).Before (YAML):
After (YAML):
Before (directory JSON - roles/Test Role.json):
{ "name": "Test Role", "description": "Role to reproduce the error", "permissions": [ { "permission_name": "some:perm", "resource_server_identifier": "https://example.com/" } ], "type": "tenant" }After (Directory JSON - roles/Test Role.json):
{ "name": "Test Role", "description": "Role to reproduce the error", "permissions": [ { "permission_name": "some:perm", "resource_server_identifier": "https://example.com/" } ] }📚 References
🔬 Testing
test/tools/auth0/handlers/roles.tests.js): asserttypenever reaches theroles.create/roles.updatepayloads, and that it is stripped fromgetType()output.export -f yamlproduces roles with notypefield; re-importing that export succeeds. Also injectedtype: tenantinto an export file (simulating a pre-fix file) and confirmed it now imports cleanly - while the same file reproduces the original400onmaster.📝 Checklist