Skip to content

feat(session)!: remove the deprecated SessionMiddleware - #402

Merged
allen0099 merged 2 commits into
masterfrom
remove/69-session-middleware
Sep 29, 2026
Merged

allen0099 merged 2 commits into
masterfrom
remove/69-session-middleware

Conversation

@allen0099

Copy link
Copy Markdown
Owner

Fixes #69.

SessionMiddleware, the header-only middleware, has been deprecated since 0.3.1 in favour of FastAPICacheXSessionMiddleware.

Code

  • Removed the class and the private _extract_header_token that only it used.
  • Removed the exports from fastapi_cachex and fastapi_cachex.session, the API reference entry, and the mentions in comments and docstrings.

Tests

  • Deleted the tests that covered only the removed class. test_get_session_manager.py and test_dependencies.py now use FastAPICacheXSessionMiddleware, and the _read_header_token tests are kept.
  • One deleted test was the only end-to-end check of user_agent_binding: FastAPICacheXSessionMiddleware never had one. It is ported in 10748b5, and it fails when the middleware stops passing the request's User-Agent.

Docs

  • SESSION.md and HTTP_CACHING.md (EN and zh-TW) now say the class was removed in 0.4.0.
  • The SESSION.md section keeps its anchor, since the migration guide links to it.

Migration: app.add_middleware(FastAPICacheXSessionMiddleware, session_manager=..., config=...).

Checks

Changelog: changelog.d/69.removed.md.

SessionMiddleware has been deprecated in favour of
FastAPICacheXSessionMiddleware since 0.3.1 and was kept until 0.4.0
because a patch release could not drop an exported class. Remove it,
its package exports, its API docs entry and the private
_extract_header_token helper only it used, together with the tests that
exercised it. Tests that installed it only to reach the session
dependencies now use FastAPICacheXSessionMiddleware, and the docs
describe it as removed.

BREAKING CHANGE: SessionMiddleware is removed; use
FastAPICacheXSessionMiddleware.
@allen0099 allen0099 added this to the 0.4.0 milestone Sep 29, 2026
@allen0099 allen0099 added session Session management subsystem breaking-change Changes public behaviour or API; needs a minor/major release labels Sep 29, 2026
@allen0099
allen0099 merged commit 4f3c7e9 into master Sep 29, 2026
15 checks passed
@allen0099
allen0099 deleted the remove/69-session-middleware branch September 29, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change Changes public behaviour or API; needs a minor/major release session Session management subsystem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0.4.0: remove the deprecated SessionMiddleware

1 participant