Skip to content

feat: update fastapi-app example - #75

Merged
tmgbedu merged 3 commits into
mainfrom
feat/example-fastapi-app
Jul 11, 2026
Merged

feat: update fastapi-app example#75
tmgbedu merged 3 commits into
mainfrom
feat/example-fastapi-app

Conversation

@tmgbedu

@tmgbedu tmgbedu commented May 28, 2026

Copy link
Copy Markdown
Contributor

Updates to fastapi-app example.

🤖 Generated with Claude Code

@tmgbedu

tmgbedu commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

✅ Reviewer verdict: APPROVE (self-approval blocked — posting as comment)

Reviewed against the 4 briefed items (task #773). All correctness checks pass.

1. Framework compatibility on FastAPI 0.139 / Starlette 0.50 — PASS

  • cd fastapi_startkit && uv sync resolves clean: fastapi 0.139.0, starlette 0.50.0, uvicorn 0.46.0.
  • uv run pytest --ignore=tests/masoniteorm/postgres486 passed, 7 skipped.
  • No FastAPI/Starlette deprecation warnings (tests/fastapi/test_router.py all green under -W default). The ~781 warnings are pre-existing SQLAlchemy GC warnings, unrelated to this bump.
  • Pins fastapi[standard]>=0.139.0,<0.140.0 (extra) and >=0.139.0 (dev) are consistent across pyproject.toml + both uv.lock files.

2. base_path — PASS

  • str(Path(__file__).parent.parent) resolves bootstrap/ → app root and is CWD-independent (verified app.base_path from the app dir and from /). Good fix over Path.cwd().

3. config/logging.py LoggingConfig — PASS

  • from fastapi_startkit.logging.config import DailyChannel, StackChannel, TerminalChannel resolves (re-exported by logging/config/__init__.py).
  • (LogProvider, LoggingConfig) tuple registration boots; example serves GET / → 200 and GET /health → 200 with logging active.

4. Ruff — PASS (CI Ruff check green; ruff check . clean locally).


Non-blocking notes

  1. Daily log path is CWD-relative, not base_path-relative. Booting the example from a different CWD (e.g. /) fails with OSError: Read-only file system: 'storage' — the daily channel writes storage/logs relative to process CWD, not app.base_path. Pre-existing framework behavior (daily driver, unchanged here), but it means the app doesn't fully boot regardless of CWD. Suggest a follow-up to join log paths against base_path.
  2. PR is currently CONFLICTING with main — needs a rebase before merge.

Verdict: APPROVE (blockers: none). Not merging (reviewer role).

@tmgbedu

tmgbedu commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

🔄 Updated verdict: REQUEST CHANGES (supersedes my earlier approve)

On a second pass — and per maintainer direction — the following need to change before this can merge. Correctness on 0.139 still checks out; these are about keeping the version pin and the example config in line with conventions.

1. Revert the FastAPI version bump — keep the pin as-is

Do not bump to 0.139.0. Restore the original pin:

  • fastapi_startkit/pyproject.toml
    • extras: fastapi[standard] (>=0.124.4,<0.125.0)
    • dev: fastapi[standard]>=0.124.4
  • Regenerate both lockfiles back to the 0.124.4 line: fastapi_startkit/uv.lock and example/fastapi-app/uv.lock (fastapi 0.124.4; drop the pulled-in pydantic-extra-types / pydantic-settings / fastar entries that only came from 0.139's standard extra).

2. example/fastapi-app/config/fastapi.py is outdated — align with the framework's canonical config

The current serve_command.py resolves the bind address from fastapi.app_url (resolve_url()Config.get('fastapi.app_url', ...)). The example still defines host/port (APP_HOST/APP_PORT), which the serve command no longer consumes — those fields are effectively dead, and app_url is missing.

  • Update FastAPIConfig to match fastapi_startkit/src/fastapi_startkit/fastapi/config/fastapi.py:
    • add app_url: str = field(default_factory=lambda: env('APP_URL', 'http://127.0.0.1:8000'))
    • drop host and port
    • keep reload, reload_dirs, reload_excludes

3. Remove the inline comment in example/fastapi-app/bootstrap/application.py

Drop the trailing comment on the base_path line:

base_path=str(Path(__file__).parent.parent),  # App root, resolved relative to this file (bootstrap/ -> root).

base_path=str(Path(__file__).parent.parent),

For reference, what still verified fine (unchanged by the above): base_path is correctly CWD-independent; LoggingConfig + (LogProvider, LoggingConfig) boots (GET / → 200, /health → 200); ruff clean. The pre-existing note about the daily log path being written relative to CWD (not base_path) still stands as a separate follow-up.

Verdict: REQUEST CHANGES — items 1–3 above. Not merging (reviewer role).

@tmgbedu

tmgbedu commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

✅ Re-review verdict: APPROVE (commit 27c4aee)

All 3 REQUEST CHANGES items are resolved. Verified locally.

1. FastAPI version reverted — ✅

  • fastapi_startkit/pyproject.toml: extras fastapi[standard] (>=0.124.4,<0.125.0), dev >=0.124.4.
  • Both lockfiles relocked to fastapi 0.124.4 (fastapi_startkit/uv.lock + example/fastapi-app/uv.lock).
  • pydantic-extra-types and pydantic-settings (the 0.139-only additions) are gone (0 refs) in both locks.
  • uv sync --locked passes → lockfiles are consistent with pyproject. Installed: fastapi 0.124.4 / starlette 0.50.0.
  • Note: fastar legitimately remains — at 0.124.4 it's a transitive dep via fastapi-cli → fastapi-cloud-cli → fastar, not a 0.139 artifact. Correct to keep. (My earlier 'drop fastar' note was mistaken; disregard it.)

2. example/fastapi-app/config/fastapi.py aligned to canonical — ✅

  • Now uses app_url (env APP_URL, default http://127.0.0.1:8000); host/port dropped; reload/reload_dirs/reload_excludes kept. Matches the framework's fastapi/config/fastapi.py, so it aligns with serve_command.resolve_url().
  • Verified at runtime: Config.get('fastapi.app_url') == 'http://127.0.0.1:8000'.

3. Inline comment removed — ✅

  • bootstrap/application.py base_path line is now clean.

Verification run

  • uv run pytest --ignore=tests/masoniteorm/postgres486 passed, 7 skipped.
  • ruff check . → clean; ruff format --check . → 406 files already formatted.
  • Example boots: GET / → 200, GET /health → 200; base_path correct.

Pre-existing non-blocking note still stands (daily log path written relative to CWD, not base_path) — separate follow-up, not part of this PR.

Reminder: PR should be rebased if it's still conflicting with main before merge.

Verdict: APPROVE. Not merging (reviewer role).

tmgbedu and others added 2 commits July 10, 2026 16:44
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…conventions

- bootstrap: derive base_path from Path(__file__).parent.parent so the app
  root (config/, storage/, routes/) resolves independently of the working
  directory instead of Path.cwd().
- Bump the framework fastapi extra and dev pin to fastapi[standard] 0.139.x
  (was capped <0.125.0) and relock both the framework and the example.
- Rewrite config/logging.py to the current LoggingConfig dataclass using the
  typed StackChannel/DailyChannel/TerminalChannel channels, and register it
  via (LogProvider, LoggingConfig) so the example's config is actually loaded.
- Add the FastAPIConfig docstring to match the framework default.
@tmgbedu
tmgbedu force-pushed the feat/example-fastapi-app branch from 27c4aee to 63e0526 Compare July 10, 2026 23:51
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@tmgbedu
tmgbedu force-pushed the feat/example-fastapi-app branch from 63e0526 to a006d37 Compare July 11, 2026 00:00
@tmgbedu
tmgbedu merged commit 7afdbb6 into main Jul 11, 2026
4 checks passed
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.

1 participant