fix: rename FastAPI Query regex= → pattern= for 0.116+ compat (#862)
FastAPI 0.116 deprecates `regex=` on Query/Path/Header/Body in favor of `pattern=`; the old kwarg now logs FastAPIDeprecationWarning on every request that hits one of these routes. Mechanical rename across all sites that triggered the warning. Pydantic Field calls (sqlmodel-backed auth models) intentionally left on `regex=` — sqlmodel.Field's signature doesn't accept `pattern` and those weren't the source of the FastAPI warning anyway. Co-authored-by: taylor_socfortress <taylor.walton@socfortress.co> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
taylorcopilot committed
May 8, 2026 at 16:37 UTC
a3738acbeceffe5e2decd8915c52e63c5017d6ed
3 files changed
+18
-18
backend/app/connectors/wazuh_manager/routes/groups.py
+3
-3
@@ -42,7 +42,7 @@ async def list_wazuh_groups(
42
hash: Optional[str] = Query(
43
None,
44
description="Select algorithm to generate the returned checksums",
45
- regex="^(md5|sha1|sha224|sha256|sha384|sha512|blake2b|blake2s|sha3_224|sha3_256|sha3_384|sha3_512)$",
45
+ pattern="^(md5|sha1|sha224|sha256|sha384|sha512|blake2b|blake2s|sha3_224|sha3_256|sha3_384|sha3_512)$",
46
),
47
q: Optional[str] = Query(None, description="Query to filter results by"),
48
select: Optional[List[str]] = Query(None, description="Select which fields to return"),
@@ -92,7 +92,7 @@ async def get_wazuh_group_files_endpoint(
92
hash: Optional[str] = Query(
93
None,
94
description="Select algorithm to generate the returned checksums",
95
- regex="^(md5|sha1|sha224|sha256|sha384|sha512|blake2b|blake2s|sha3_224|sha3_256|sha3_384|sha3_512)$",
95
+ pattern="^(md5|sha1|sha224|sha256|sha384|sha512|blake2b|blake2s|sha3_224|sha3_256|sha3_384|sha3_512)$",
96
),
97
q: Optional[str] = Query(None, description="Query to filter results by"),
98
select: Optional[List[str]] = Query(None, description="Select which fields to return"),
@@ -140,7 +140,7 @@ async def get_wazuh_group_file_endpoint(
140
filename: str = Path(..., description="Filename (e.g., agent.conf)"),
141
pretty: Optional[bool] = Query(False, description="Show results in human-readable format"),
142
wait_for_complete: Optional[bool] = Query(False, description="Disable timeout response"),
143
- type: Optional[List[str]] = Query(None, description="Type of file", regex="^(conf|rootkit_files|rootkit_trojans|rcl)$"),
143
+ type: Optional[List[str]] = Query(None, description="Type of file", pattern="^(conf|rootkit_files|rootkit_trojans|rcl)$"),
144
raw: Optional[bool] = Query(True, description="Format response in plain text"),
145
) -> WazuhGroupFileResponse:
146
"""
backend/app/incidents/routes/db_operations.py
+10
-10
@@ -1192,7 +1192,7 @@ async def get_case_filter_options_endpoint(
1192
async def list_alerts_endpoint(
1193
page: int = Query(1, ge=1),
1194
page_size: int = Query(25, ge=1),
1195
- order: str = Query("desc", regex="^(asc|desc)$"),
1195
+ order: str = Query("desc", pattern="^(asc|desc)$"),
1196
current_user: User = Depends(AuthHandler().get_current_user),
1197
db: AsyncSession = Depends(get_db),
1198
):
@@ -1388,7 +1388,7 @@ async def list_alerts_by_status_endpoint(
1388
status: AlertStatus,
1389
page: int = Query(1, ge=1),
1390
page_size: int = Query(25, ge=1),
1391
- order: str = Query("desc", regex="^(asc|desc)$"),
1391
+ order: str = Query("desc", pattern="^(asc|desc)$"),
1392
current_user: User = Depends(AuthHandler().get_current_user),
1393
db: AsyncSession = Depends(get_db),
1394
):
@@ -1445,7 +1445,7 @@ async def list_alerts_by_assigned_to_endpoint(
1445
assigned_to: str,
1446
page: int = Query(1, ge=1),
1447
page_size: int = Query(25, ge=1),
1448
- order: str = Query("desc", regex="^(asc|desc)$"),
1448
+ order: str = Query("desc", pattern="^(asc|desc)$"),
1449
current_user: User = Depends(AuthHandler().get_current_user),
1450
db: AsyncSession = Depends(get_db),
1451
):
@@ -1497,7 +1497,7 @@ async def list_alerts_by_asset_name_endpoint(
1497
asset_name: str,
1498
page: int = Query(1, ge=1),
1499
page_size: int = Query(25, ge=1),
1500
- order: str = Query("desc", regex="^(asc|desc)$"),
1500
+ order: str = Query("desc", pattern="^(asc|desc)$"),
1501
current_user: User = Depends(AuthHandler().get_current_user),
1502
db: AsyncSession = Depends(get_db),
1503
):
@@ -1549,7 +1549,7 @@ async def list_alerts_by_title_endpoint(
1549
title: str,
1550
page: int = Query(1, ge=1),
1551
page_size: int = Query(25, ge=1),
1552
- order: str = Query("desc", regex="^(asc|desc)$"),
1552
+ order: str = Query("desc", pattern="^(asc|desc)$"),
1553
current_user: User = Depends(AuthHandler().get_current_user),
1554
db: AsyncSession = Depends(get_db),
1555
):
@@ -1601,7 +1601,7 @@ async def list_alerts_by_customer_code_endpoint(
1601
customer_code: str,
1602
page: int = Query(1, ge=1),
1603
page_size: int = Query(25, ge=1),
1604
- order: str = Query("desc", regex="^(asc|desc)$"),
1604
+ order: str = Query("desc", pattern="^(asc|desc)$"),
1605
current_user: User = Depends(customer_access_handler.require_customer_access()),
1606
db: AsyncSession = Depends(get_db),
1607
):
@@ -1630,7 +1630,7 @@ async def list_alerts_by_source_endpoint(
1630
source: str,
1631
page: int = Query(1, ge=1),
1632
page_size: int = Query(25, ge=1),
1633
- order: str = Query("desc", regex="^(asc|desc)$"),
1633
+ order: str = Query("desc", pattern="^(asc|desc)$"),
1634
current_user: User = Depends(AuthHandler().get_current_user),
1635
db: AsyncSession = Depends(get_db),
1636
):
@@ -1689,7 +1689,7 @@ async def list_alerts_multiple_filters_endpoint(
1689
ioc_value: Optional[str] = Query(None),
1690
page: int = Query(1, ge=1),
1691
page_size: int = Query(25, ge=1),
1692
- order: str = Query("desc", regex="^(asc|desc)$"),
1692
+ order: str = Query("desc", pattern="^(asc|desc)$"),
1693
current_user: User = Depends(AuthHandler().get_current_user),
1694
db: AsyncSession = Depends(get_db),
1695
):
@@ -1767,7 +1767,7 @@ async def list_alerts_multiple_filters_endpoint(
1767
async def list_cases_endpoint(
1768
page: int = Query(1, ge=1),
1769
page_size: int = Query(25, ge=1),
1770
- order: str = Query("desc", regex="^(asc|desc)$"),
1770
+ order: str = Query("desc", pattern="^(asc|desc)$"),
1771
current_user: User = Depends(AuthHandler().get_current_user),
1772
db: AsyncSession = Depends(get_db),
1773
):
@@ -2118,7 +2118,7 @@ async def list_cases_by_status_endpoint(
2118
status: AlertStatus,
2119
page: int = Query(1, ge=1),
2120
page_size: int = Query(25, ge=1),
2121
- order: str = Query("desc", regex="^(asc|desc)$"),
2121
+ order: str = Query("desc", pattern="^(asc|desc)$"),
2122
current_user: User = Depends(AuthHandler().get_current_user),
2123
db: AsyncSession = Depends(get_db),
2124
):
backend/app/integrations/microsoft_patch_tuesday/routes/microsoft_patch_tuesday.py
+5
-5
@@ -45,7 +45,7 @@ async def get_patch_tuesday_data(
45
cycle: Optional[str] = Query(
46
None,
47
description="Cycle in YYYY-Mmm format (e.g., 2026-Jan). Defaults to current month.",
48
- regex=r"^\d{4}-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)$",
48
+ pattern=r"^\d{4}-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)$",
49
),
50
include_epss: bool = Query(True, description="Include EPSS scores in the response"),
51
include_kev: bool = Query(True, description="Include CISA KEV data in the response"),
@@ -87,7 +87,7 @@ async def get_patch_tuesday_summary_endpoint(
87
cycle: Optional[str] = Query(
88
None,
89
description="Cycle in YYYY-Mmm format (e.g., 2026-Jan). Defaults to current month.",
90
- regex=r"^\d{4}-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)$",
90
+ pattern=r"^\d{4}-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)$",
91
),
92
include_epss: bool = Query(True, description="Include EPSS scores in the response"),
93
include_kev: bool = Query(True, description="Include CISA KEV data in the response"),
@@ -138,7 +138,7 @@ async def search_cves(
138
cycle: Optional[str] = Query(
139
None,
140
description="Cycle in YYYY-Mmm format to limit search to. Defaults to current month.",
141
- regex=r"^\d{4}-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)$",
141
+ pattern=r"^\d{4}-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)$",
142
),
143
) -> PatchTuesdayResponse:
144
"""
@@ -162,7 +162,7 @@ async def get_by_priority(
162
cycle: Optional[str] = Query(
163
None,
164
description="Cycle in YYYY-Mmm format. Defaults to current month.",
165
- regex=r"^\d{4}-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)$",
165
+ pattern=r"^\d{4}-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)$",
166
),
167
include_epss: bool = Query(True, description="Include EPSS scores"),
168
include_kev: bool = Query(True, description="Include CISA KEV data"),
@@ -245,7 +245,7 @@ async def get_kev_items(
245
cycle: Optional[str] = Query(
246
None,
247
description="Cycle in YYYY-Mmm format. Defaults to current month.",
248
- regex=r"^\d{4}-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)$",
248
+ pattern=r"^\d{4}-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)$",
249
),
250
) -> PatchTuesdayResponse:
251
"""