Repository navigation
fix: reject dot-segment path parameters - #1441
Draft
ankita10119 wants to merge 1 commit into
Draft
ankita10119 wants to merge 1 commit into
ankita10119 wants to merge 1 commit into
Conversation
Path parameters that are exactly "." or ".." now throw ManagementError before any request is sent, matching the behaviour added in v7.6.0.
ankita10119
marked this pull request as draft
November 11, 2026 18:31
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v5 #1441 +/- ##
==========================================
+ Coverage 89.62% 89.64% +0.01%
==========================================
Files 428 428
Lines 19886 19891 +5
Branches 9400 9402 +2
==========================================
+ Hits 17823 17831 +8
+ Misses 2063 2060 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This branch has not been deployed
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
Path parameters are encoded with
encodePathParam, which usesencodeURIComponentand leaves.unchanged. When a path parameter is exactly.or.., URL resolution removes it as a dot segment, so the request (with the Management API token attached) is sent to a different path than the one the method targets. For example,users.roles.list('..')was sent asGET /api/v2/roles, andusers.delete('..')asDELETE /api/v2/.This backports the v7.6.0 fix to 5.x:
src/management/core/url/encodePathParam.ts: rejects.and.., throwing the error class passed in (or a plainError). This file is identical to the one in v7.6.0.src/management/api/(101 files): everycore.url.encodePathParam(x)call now passeserrors.ManagementErroras the second argument, as in v7.6.0. This is the only change in these files, so callers get aManagementErrorlike any other SDK error.src/management/tests/unit/url/encodePathParam.test.ts: new unit tests, identical to v7.6.0.The check runs while the request path is being built, so a rejected call never sends the request. Values such as
...,a.b,auth0|a.band%2e%2eare unaffected (%2e%2eis encoded as%252e%252e).No endpoints were added, removed or deprecated. The only behaviour change: a call whose path parameter is exactly
.or..now throwsManagementErrorinstead of being sent to a different endpoint.Alternatives considered:
.as%2E. That doesn't work, because WHATWG URL parsing also treats%2e%2e,.%2eand%2e.as.., so these values are rejected instead.encodePathParam.ts(a 1-file diff). That would throw a plainErrorinstead ofManagementError. The call-site change keeps the error type consistent with v7.6.0 and with existinginstanceof ManagementErrorhandling.References
Testing
New unit tests in
src/management/tests/unit/url/encodePathParam.test.ts(18 tests):.and..are rejected, and the provided error class is thrownusr_123,a/b,...,a..b,%2E%2E,"", numbers, booleans,null,undefined)With only the dot-segment check disabled, the 3 rejection tests fail.
Verified locally:
yarn lint(no new warnings),yarn build(CJS and ESM) andyarn lint:packagepassyarn test: 205/205 suites, 4494 passed. The 1 skipped test is a pre-existingit.skipintests/management/token-provider.test.ts. The wire tests exercise the changed client methods with normal IDs.fetch(Node 18.20.8 and 24.0.1), with both a static token and client credentials:users.roles.list('..')is sent toGET /api/v2/rolesandusers.delete('..')toDELETE /api/v2/, with the token..and.onusers.roles.list,users.get,users.deleteandroles.getthrowManagementErrorand nothing is sent; normal IDs such asauth0|a.bare unchangedChecklist