Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: mozilla-ai/otari/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (6)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review. WalkthroughChangesManagement-plane routes now resolve the model-provider port with the route’s existing Shared model-provider session
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to The management routes now reuse their request database session, while data-plane routes retain their existing dependency. No merge-blocking risk was identified. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to Existing access checks remain in place, and the built-in provider does not use the session. The change could affect deployment-specific providers that read or write data, but their behavior has not been verified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Hardening Proposals
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Title checkExplanation The title accurately describes the change and uses imperative mood, but it uses the scoped form
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
b83219b to
d42d385
Compare
…r port Catalog, models, organization pricing, organization routing, and the playground chat route take get_db for their session but resolved ModelProviderPort through get_model_provider_port, which takes its session from get_db_if_needed. FastAPI treats those as separate dependencies and opens a second, independent session for the port instead of sharing the caller's. Added get_model_provider_port_shared, which takes the session from get_db directly like the three sibling ports already do, and switched those five routes to it. Chat, messages, and responses keep the existing dependency: they take get_db_if_needed themselves, and hybrid mode has no local database at all. Fixes mozilla-ai#1266
d42d385 to
d7101f8
Compare
|
CI is green here and it's been about a week with no review yet. Let me know if anything needs more context. |
Description
Catalog, models, organization pricing, organization routing, and the playground chat route resolve
ModelProviderPortthroughget_model_provider_port, which takes its session fromget_db_if_needed. Since these routes takeget_dbfor their own session, FastAPI treats the two as separate dependencies and opens a second, independent session for the port instead of sharing the caller's. Addedget_model_provider_port_shared, which takes the session fromget_dbdirectly like the three sibling ports (get_growth_signal_port,get_identity_provider_port,get_telemetry_storage_port) already do, and switched those five routes to it.Chat, messages, and responses keep the existing
get_model_provider_port: they takeget_db_if_neededthemselves, and hybrid mode has no local database at all.The core
SelfHostedModelProviderAdapterdiscards the session it's given, so nothing observable changes for the OSS edition today. An overlay adapter that reads or writes through the port on one of these five routes is the one this fixes for.How to test it locally
uv run pytest tests/unit/test_model_provider_port_management_route_session.py. It buildsget_organization_pricing_servicebehind a bare route and checks the sessionModelProviderPortgets built with is the same object as the route's owndb; red without the change, green with it.PR Type
Relevant issues
Fixes #1266
Checklist
tests/unit,tests/integration).make lint,make typecheck,make test).uv run python scripts/generate_openapi.py).ARCHITECTURE.mdorscripts/check_architecture.py, the description names the rule and says why.make lint,make typecheck, the openapi/postman/architecture checks, and the unit suite all pass locally. Could not gettest-integrationrunning in my sandbox (its Postgres testcontainer needs a Docker socket my own container can't reach), so that leg is unverified here; nothing in the diff touches a route schema or a migration.AI Usage
AI Model/Tool used:
Any additional AI details you'd like to share:
Summary
This avoids opening an extra database connection on the updated routes.