mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-26 23:51:14 +02:00
feat: validate web.crawl start URLs
This commit is contained in:
parent
797dd2df47
commit
a123c95703
2 changed files with 8 additions and 1 deletions
|
|
@ -18,6 +18,8 @@ from typing import Literal
|
|||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from app.capabilities.core.validation import HttpUrlStr
|
||||
|
||||
MAX_START_URLS = 20
|
||||
"""Per-call cap on seed URLs: bounds a synchronous request's fan-out (05)."""
|
||||
|
||||
|
|
@ -29,7 +31,7 @@ MAX_CRAWL_PAGES = 200
|
|||
|
||||
|
||||
class CrawlInput(BaseModel):
|
||||
startUrls: list[str] = Field(
|
||||
startUrls: list[HttpUrlStr] = Field(
|
||||
min_length=1,
|
||||
max_length=MAX_START_URLS,
|
||||
description=(
|
||||
|
|
|
|||
|
|
@ -20,6 +20,11 @@ def test_requires_at_least_one_start_url() -> None:
|
|||
CrawlInput(startUrls=[])
|
||||
|
||||
|
||||
def test_rejects_malformed_start_url() -> None:
|
||||
with pytest.raises(ValidationError):
|
||||
CrawlInput(startUrls=["not-a-url"])
|
||||
|
||||
|
||||
def test_camelcase_fields_and_defaults() -> None:
|
||||
model = CrawlInput(startUrls=["https://e.com"])
|
||||
assert model.startUrls == ["https://e.com"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue