mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
fix(mcp): enforce MAX_PAGE_SIZE limit on list tools to prevent oversized responses (#38959)
This commit is contained in:
@@ -28,6 +28,7 @@ from superset.mcp_service.chart.schemas import (
|
||||
ChartFilter,
|
||||
ListChartsRequest,
|
||||
)
|
||||
from superset.mcp_service.constants import MAX_PAGE_SIZE
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -133,6 +134,19 @@ class TestListChartsRequestSchema:
|
||||
with pytest.raises(ValueError, match="Input should be greater than 0"):
|
||||
ListChartsRequest(page_size=0)
|
||||
|
||||
def test_page_size_exceeds_max(self):
|
||||
"""Test that page_size over MAX_PAGE_SIZE raises validation error."""
|
||||
with pytest.raises(
|
||||
ValueError,
|
||||
match=f"Input should be less than or equal to {MAX_PAGE_SIZE}",
|
||||
):
|
||||
ListChartsRequest(page_size=MAX_PAGE_SIZE + 1)
|
||||
|
||||
def test_page_size_at_max(self):
|
||||
"""Test that page_size at MAX_PAGE_SIZE is accepted."""
|
||||
request = ListChartsRequest(page_size=MAX_PAGE_SIZE)
|
||||
assert request.page_size == MAX_PAGE_SIZE
|
||||
|
||||
def test_filter_validation(self):
|
||||
"""Test that filter validation works correctly."""
|
||||
# Valid filter
|
||||
|
||||
Reference in New Issue
Block a user