Skip to content

fix/rate-limit-root-path-prefix-4994#5018

Open
Nayana-R-Gowda wants to merge 1 commit into
mainfrom
fix/rate-limit-root-path-prefix-4994
Open

fix/rate-limit-root-path-prefix-4994#5018
Nayana-R-Gowda wants to merge 1 commit into
mainfrom
fix/rate-limit-root-path-prefix-4994

Conversation

@Nayana-R-Gowda
Copy link
Copy Markdown
Collaborator

@Nayana-R-Gowda Nayana-R-Gowda commented Jun 3, 2026

Signed-off-by: NAYANA.R nayana.r7813@gmail.com

closes #4994
Changes Made

mcpgateway/middleware/rate_limit_middleware.py

1.get_endpoint_tier() (line 169): Changed signature from (self, path: str) to (self, request_or_path) — now accepts either a Request object or a string. When a Request is passed, strips the root_path prefix before pattern matching.

2._get_tier_name() (line 295): Same treatment — accepts Request or str, strips root_path when a Request is passed.

3.dispatch() (lines 227, 230): Now passes request directly instead of request.url.path.

tests/unit/mcpgateway/middleware/test_rate_limit_middleware.py

1 .test_endpoint_tier_strips_root_path — 10 cases covering various root_path values and tier types
2 .test_endpoint_tier_root_path_edge_cases — 5 edge cases (trailing slash, / root, partial match prevention, empty root_path)

AFTER:
tier = self.get_endpoint_tier(request)
dimensions = self._get_client_dimensions(request)
tier_name = self._get_tier_name(request)

Signed-off-by: NAYANA.R <nayana.r7813@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ica ICA related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Rate limit middleware does not strip root_path prefix — all requests fall into LOW tier

1 participant