Skip to content

🐛 Use current Starlette middleware conventions#202

Merged
esnible merged 2 commits intokagenti:mainfrom
esnible:fix-weather-service
Mar 26, 2026
Merged

🐛 Use current Starlette middleware conventions#202
esnible merged 2 commits intokagenti:mainfrom
esnible:fix-weather-service

Conversation

@esnible
Copy link
Copy Markdown
Contributor

@esnible esnible commented Mar 25, 2026

Summary

Recent PR #201 broke the weather service.
I had tested it, but then CI asked me to update Starlette, which I did -- without re-testing.

(Optional) Testing Instructions

Run uv run --no-sync server in the a2a/weather_service directory. It fails before this change, it succeeds after it.
Or build from source with Kagenti and ask it about the weather.

esnible added 2 commits March 25, 2026 15:39
Signed-off-by: Ed Snible <snible@us.ibm.com>
Signed-off-by: Ed Snible <snible@us.ibm.com>
@esnible esnible marked this pull request as ready for review March 25, 2026 20:47
@esnible esnible changed the title Bug: Use current Starlette middleware conventions 🐛 Use current Starlette middleware conventions Mar 25, 2026
Copy link
Copy Markdown
Contributor

@rubambiza rubambiza left a comment

Choose a reason for hiding this comment

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

Tested locally — confirmed the fix.

Without fix: AttributeError: 'Starlette' object has no attribute 'middleware'. Did you mean: 'add_middleware'?
With fix: Server starts cleanly on http://0.0.0.0:8000.

The migration from @app.middleware("http") to BaseHTTPMiddleware subclass is the correct pattern for Starlette 1.0.

Side note from testing: The breakage isn't reproducible on main alone because the lock file still resolves to starlette==0.46.2 (constrained by fastapi<0.48.0). It only manifests when the lock file is regenerated with the PR #201 dependency bumps, which pull in starlette==1.0.0. This means the lock file committed in #201 was likely regenerated after the pyproject.toml pin for starlette>=0.49.1 was added but the code wasn't re-tested against the new resolution — which matches what you described in the PR body.

@esnible esnible merged commit 74c2cf6 into kagenti:main Mar 26, 2026
9 checks passed
@esnible esnible deleted the fix-weather-service branch March 26, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants