Skip to content

Fix test_websocket_endpoint_added for newer FastAPI - #53

Closed
tschm wants to merge 0 commit into
alihaskar:masterfrom
tschm:fix-included-router-route-path
Closed

tschm wants to merge 0 commit into
alihaskar:masterfrom
tschm:fix-included-router-route-path

Conversation

@tschm

@tschm tschm commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

CI test test_websocket_endpoint_added failed with AttributeError: '_IncludedRouter' object has no attribute 'path'.

Newer FastAPI versions append an _IncludedRouter marker object to app.routes when include_router is called. That object has no path attribute, so the route lookup in the test crashed.

Fix

Guard the attribute access with getattr(route, "path", None), skipping marker objects while still finding the /ws/heartbeat route. This is a test-only change; no production code affected.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 17, 2026 06:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates a lifecycle test to be compatible with newer FastAPI behavior where include_router appends an _IncludedRouter marker object (without a path attribute) into app.routes, preventing an AttributeError during route inspection.

Changes:

  • Avoids direct route.path access in test_websocket_endpoint_added by using getattr(route, "path", None) when collecting route paths.
  • Adds an explanatory comment documenting why the guard is needed for newer FastAPI versions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tschm tschm closed this Jul 20, 2026
@tschm
tschm force-pushed the fix-included-router-route-path branch from 2107521 to ba1b49a Compare July 20, 2026 07:21
@tschm
tschm deleted the fix-included-router-route-path branch July 20, 2026 07:22

This branch was previously deployed

1 inactive deployment
github-pages — ba1b49a0 Deployed Jul 20, 2026 by alihaskar via book / deploy #12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants