Skip to content

fix: read provider config from Settings in FastAPI router - #47

Merged
johnnyhuy merged 3 commits into
mainfrom
fix/router-settings-config
Oct 3, 2026
Merged

johnnyhuy merged 3 commits into
mainfrom
fix/router-settings-config

Conversation

@johnnyhuy

Copy link
Copy Markdown
Contributor

Summary

  • Fix FastAPI dev path reads provider keys from os.environ instead of Settings; .env alone yields misleading "Unknown model" #46: the FastAPI dev-path Router resolved provider API keys/base URLs from os.environ directly, so the documented .env-only setup produced a misleading 400 Unknown model instead of configuring the provider. It now delegates to the shared bridge resolvers (mojo_bridge.routing), so both servers resolve routes, keys, and base URLs identically via Settings.
  • Split the error paths: 400 Unknown model: {model} (no route) vs 503 no API key configured for provider {module} (route matched, gateway not configured).
  • Add tests/conftest.py suite-wide hermetic settings — a local .env leaking into the suite is the same bug class (5 existing tests failed whenever one was present).
  • Regression tests: .env-only config serves requests; unknown-model vs missing-key produce distinct errors.
  • Docs: "Demo without an API key" README section using the bundled tests/mock_upstream.py.
  • Chore: gitignore .playwright-mcp/.

Closes #46

Consequences

  • Router.select_provider now raises ProviderNotConfiguredError (instead of returning None) when a route matches but no key is configured; callers outside main.py would need the same handling. None in-tree.
  • claude-*/bedrock/* etc. now resolve to their real provider modules on the FastAPI path (previously everything mapped to OpenAI) — matching the Mojo bridge and removing drift.

Testing

  • CI locally: ruff check ✓, ruff format --check ✓, mypy ✓, pytest 60 passed (up from 55 + 5 env-contaminated failures)
  • Live: .env-only startup now serves 200 completions; 400/503 error split verified with curl; live end-to-end run against the mimo OpenAI-compatible API (non-streaming + SSE streaming) through ROUTES_JSON

johnnyhuy and others added 3 commits October 3, 2026 21:30
The dev-path Router resolved API keys and base URLs from os.environ
directly, so a .env file alone (the documented setup) produced a
misleading "Unknown model" 400 instead of configuring the provider.
Delegate to the shared bridge resolvers (mojo_bridge.routing) so both
servers resolve routes, keys, and base URLs identically via Settings,
and split the error paths: 400 unknown model vs 503 no API key
configured.

Also adds suite-wide hermetic settings (tests/conftest.py): a local
.env leaking into the suite is the same bug class, and 5 existing
tests failed whenever one was present.

Closes #46

Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com>
Show how to run the full gateway path offline with the bundled
tests/mock_upstream.py instead of a paid API key.

Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com>
@johnnyhuy
johnnyhuy enabled auto-merge (squash) October 3, 2026 11:31
@johnnyhuy
johnnyhuy merged commit ad2223d into main Oct 3, 2026
13 checks passed
@johnnyhuy
johnnyhuy deleted the fix/router-settings-config branch October 3, 2026 11:32
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.

FastAPI dev path reads provider keys from os.environ instead of Settings; .env alone yields misleading "Unknown model"

1 participant