Compare commits

...

6 Commits

Author SHA1 Message Date
github-actions[bot]
8bdb0d2242 📝 Update release notes
[skip ci]
2026-02-10 10:59:10 +00:00
Javier Sánchez Castro
df950111fe Show a clear error on attempt to include router into itself (#14258)
Co-authored-by: Javier Sánchez <javier.sanchez.castro@bookline.ai>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
2026-02-10 11:58:40 +01:00
github-actions[bot]
363aced75a 📝 Update release notes
[skip ci]
2026-02-10 10:52:51 +00:00
rijenkii
66dc695071 Replace dict by Mapping on HTTPException.headers (#12997)
Co-authored-by: Alejandra <90076947+alejsdev@users.noreply.github.com>
Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
2026-02-10 11:52:24 +01:00
github-actions[bot]
e94028ab60 📝 Update release notes
[skip ci]
2026-02-09 17:39:11 +00:00
Motov Yurii
8fd291465b 🔧 Configure test workflow to run tests with inline-snapshot=review (#14876) 2026-02-09 18:38:48 +01:00
5 changed files with 28 additions and 2 deletions

View File

@@ -14,6 +14,7 @@ on:
env:
UV_NO_SYNC: true
INLINE_SNAPSHOT_DEFAULT_FLAGS: review
jobs:
changes:

View File

@@ -7,6 +7,15 @@ hide:
## Latest Changes
### Features
* ✨ Show a clear error on attempt to include router into itself. PR [#14258](https://github.com/fastapi/fastapi/pull/14258) by [@JavierSanchezCastro](https://github.com/JavierSanchezCastro).
* ✨ Replace `dict` by `Mapping` on `HTTPException.headers`. PR [#12997](https://github.com/fastapi/fastapi/pull/12997) by [@rijenkii](https://github.com/rijenkii).
### Internal
* 🔧 Configure `test` workflow to run tests with `inline-snapshot=review`. PR [#14876](https://github.com/fastapi/fastapi/pull/14876) by [@YuriiMotov](https://github.com/YuriiMotov).
## 0.128.6
### Fixes

View File

@@ -1,4 +1,4 @@
from collections.abc import Sequence
from collections.abc import Mapping, Sequence
from typing import Annotated, Any, Optional, TypedDict, Union
from annotated_doc import Doc
@@ -68,7 +68,7 @@ class HTTPException(StarletteHTTPException):
),
] = None,
headers: Annotated[
Optional[dict[str, str]],
Optional[Mapping[str, str]],
Doc(
"""
Any headers to send to the client in the response.

View File

@@ -1393,6 +1393,10 @@ class APIRouter(routing.Router):
app.include_router(internal_router)
```
"""
assert self is not router, (
"Cannot include the same APIRouter instance into itself. "
"Did you mean to include a different router?"
)
if prefix:
assert prefix.startswith("/"), "A path prefix must start with '/'"
assert not prefix.endswith("/"), (

View File

@@ -0,0 +1,12 @@
import pytest
from fastapi import APIRouter
def test_router_circular_import():
router = APIRouter()
with pytest.raises(
AssertionError,
match="Cannot include the same APIRouter instance into itself. Did you mean to include a different router?",
):
router.include_router(router)